GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Why Go
  • Case Studies
  • Use Cases
  • Security
  • Learn
  • Effective Go
  • Go User Manual
  • Standard library
  • Release Notes
  • API
  • Packages
  • Recorded Talks
  • Meetups
  • Conferences

This view

  • Original page
  • New address

GeezerVison is showing pkg.go.dev — internal package - net/http/internal - Go Packages

Details

  • checked Valid go.mod file

    The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.

  • checked Redistributable license

    Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.

  • checked Tagged version

    Modules with tagged versions give importers more predictable builds.

  • checked Stable version

    When a project reaches major version v1 it is considered stable.

  • Learn more about best practices

Repository

cs.opensource.google/go/go

Links

  • Report a Vulnerability

Documentation ¶

Overview ¶

Package internal contains HTTP internals shared by net/http and net/http/httputil.

Index ¶

  • Constants
  • Variables
  • func DetectContentType(data []byte) string
  • func NewChunkedReader(r io.Reader) io.Reader
  • func NewChunkedWriter(w io.Writer) io.WriteCloser
  • type FlushAfterChunkWriter

Constants ¶

View Source
const SniffLen = 512

The algorithm uses at most SniffLen bytes to make its decision.

Variables ¶

View Source
var (
	ErrAbortHandler    = errors.New("net/http: abort Handler")
	ErrBodyNotAllowed  = errors.New("http: request method or response status code does not allow body")
	ErrRequestCanceled = errors.New("net/http: request canceled")
	ErrSkipAltProtocol = errors.New("net/http: skip alternate protocol")
)
View Source
var ErrLineTooLong = errors.New("header line too long")

Functions ¶

func DetectContentType ¶ added in go1.27.0

func DetectContentType(data []byte) string

DetectContentType implements the algorithm described at https://mimesniff.spec.whatwg.org/ to determine the Content-Type of the given data. It considers at most the first 512 bytes of data. DetectContentType always returns a valid MIME type: if it cannot determine a more specific one, it returns "application/octet-stream".

func NewChunkedReader ¶

func NewChunkedReader(r io.Reader) io.Reader

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 NewChunkedWriter ¶

func NewChunkedWriter(w io.Writer) io.WriteCloser

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.

Types ¶

type FlushAfterChunkWriter ¶ added in go1.5

type FlushAfterChunkWriter struct {
	*bufio.Writer
}

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.

Source Files ¶

View all Source files
  • chunked.go
  • common.go
  • sniff.go

Directories ¶

Path Synopsis
ascii
http2
Package http2 implements the HTTP/2 protocol.
Package http2 implements the HTTP/2 protocol.
httpcommon
httpsfv
testcert
Package testcert contains a test-only localhost certificate.
Package testcert contains a test-only localhost certificate.
Click to show internal directories.
Click to hide internal directories.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.