func (w *fragmentingWriter) Write(b []byte) (int, error) {
	if w.err != nil {
		return 0, w.err
	}

	if !w.state.isWritingArgument() {
		w.err = errNotWritingArgument
		return 0, w.err
	}

	totalWritten := 0
	for {
		bytesWritten := w.curChunk.writeAsFits(b)
		totalWritten += bytesWritten
		if bytesWritten == len(b) {
			// The whole thing fit, we're done
			return totalWritten, nil
		}

		// There was more data than fit into the fragment, so flush the current fragment,
		// start a new fragment and chunk, and continue writing
		if w.err = w.Flush(); w.err != nil {
			return totalWritten, w.err
		}

		b = b[bytesWritten:]
	}
}
func (w *fragmentingWriter) Write(b []byte) (int, error) {
	if w.err != nil {
		return 0, w.err
	}

	if !w.state.isWritingArgument() {
		w.err = errNotWritingArgument
		return 0, w.err
	}

	totalWritten := 0
	for {
		bytesWritten := w.curChunk.writeAsFits(b)
		totalWritten += bytesWritten
		if bytesWritten == len(b) {
			
			return totalWritten, nil
		}

		
		
		if w.err = w.Flush(); w.err != nil {
			return totalWritten, w.err
		}

		b = b[bytesWritten:]
	}
}
func ( w * fragmentingWriter ) Write ( b [ ] byte ) ( int , error ) { if w . err != nil { return 0 , w . err } if ! w . state . isWritingArgument ( ) { w . err = errNotWritingArgument return 0 , w . err } totalWritten := 0 for { bytesWritten := w . curChunk . writeAsFits ( b ) totalWritten += bytesWritten if bytesWritten == len ( b ) { // The whole thing fit, we're done return totalWritten , nil } // There was more data than fit into the fragment, so flush the current fragment, // start a new fragment and chunk, and continue writing if w . err = w . Flush ( ) ; w . err != nil { return totalWritten , w . err } b = b [ bytesWritten : ] } }
// Write writes argument data, breaking it into fragments as needed
Write writes argument data breaking it into fragments as needed