internal

Imports

Imports #

"bufio"
"bytes"
"errors"
"fmt"
"io"

Constants & Variables

ErrLineTooLong var #

var ErrLineTooLong = *ast.CallExpr

maxLineLength const #

const maxLineLength = 4096

semi var #

var semi = *ast.CallExpr

Structs

FlushAfterChunkWriter struct #

FlushAfterChunkWriter signals from the caller of [NewChunkedWriter] that each chunk should be followed by a flush. It is used by the [net/http.Transport] code to keep the buffering behavior for headers and trailers, but flush out chunks aggressively in the middle for request bodies which may be generated slowly. See Issue 6574.

type FlushAfterChunkWriter struct {
*bufio.Writer
}

chunkedReader struct #

type chunkedReader struct {
r *bufio.Reader
n uint64
err error
buf [2]byte
checkEnd bool
excess int64
}

chunkedWriter struct #

Writing to chunkedWriter translates to writing in HTTP chunked Transfer Encoding wire format to the underlying Wire chunkedWriter.

type chunkedWriter struct {
Wire io.Writer
}

Functions

Close method #

func (cw *chunkedWriter) Close() error

NewChunkedReader function #

NewChunkedReader returns a new chunkedReader that translates the data read from r out of HTTP "chunked" format before returning it. The chunkedReader returns [io.EOF] when the final 0-length chunk is read. NewChunkedReader is not needed by normal applications. The http package automatically decodes chunking when reading response bodies.

func NewChunkedReader(r io.Reader) io.Reader

NewChunkedWriter function #

NewChunkedWriter returns a new chunkedWriter that translates writes into HTTP "chunked" format before writing them to w. Closing the returned chunkedWriter sends the final 0-length chunk that marks the end of the stream but does not send the final CRLF that appears after trailers; trailers and the last CRLF must be written separately. NewChunkedWriter is not needed by normal applications. The http package adds chunking automatically if handlers don't set a Content-Length header. Using newChunkedWriter inside a handler would result in double chunking or chunking with a Content-Length length, both of which are wrong.

func NewChunkedWriter(w io.Writer) io.WriteCloser

Read method #

func (cr *chunkedReader) Read(b []uint8) (n int, err error)

Write method #

Write the contents of data as one chunk to Wire. NOTE: Note that the corresponding chunk-writing procedure in Conn.Write has a bug since it does not check for success of [io.WriteString]

func (cw *chunkedWriter) Write(data []byte) (n int, err error)

beginChunk method #

func (cr *chunkedReader) beginChunk()

chunkHeaderAvailable method #

func (cr *chunkedReader) chunkHeaderAvailable() bool

isOWS function #

func isOWS(b byte) bool

parseHexUint function #

func parseHexUint(v []byte) (n uint64, err error)

readChunkLine function #

Read a line of bytes (up to \n) from b. Give up if the line exceeds maxLineLength. The returned bytes are owned by the bufio.Reader so they are only valid until the next bufio read.

func readChunkLine(b *bufio.Reader) ([]byte, error)

removeChunkExtension function #

removeChunkExtension removes any chunk-extension from p. For example, "0" => "0" "0;token" => "0" "0;token=val" => "0" `0;token="quoted string"` => "0"

func removeChunkExtension(p []byte) ([]byte, error)

trimTrailingWhitespace function #

func trimTrailingWhitespace(b []byte) []byte

Generated with Arrow