All packages

net/http

import "net/http"

Go 1.26.1

Constants

const DefaultMaxHeaderBytes = 1 << 20 // 1 MB

DefaultMaxHeaderBytes is the maximum permitted size of the headers in an HTTP request. This can be overridden by setting [Server.MaxHeaderBytes].

net/http/server.go:895

const DefaultMaxIdleConnsPerHost = 2

DefaultMaxIdleConnsPerHost is the default value of [Transport]'s MaxIdleConnsPerHost.

net/http/transport.go:61

const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH" // RFC 5789
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	Meth...

Common HTTP methods. Unless otherwise noted, these are defined in RFC 7231 section 4.3.

net/http/method.go:17

const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH" // RFC 5789
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	Meth...

Common HTTP methods. Unless otherwise noted, these are defined in RFC 7231 section 4.3.

net/http/method.go:16

const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH" // RFC 5789
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	Meth...

Common HTTP methods. Unless otherwise noted, these are defined in RFC 7231 section 4.3.

net/http/method.go:11

const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH" // RFC 5789
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	Meth...

Common HTTP methods. Unless otherwise noted, these are defined in RFC 7231 section 4.3.

net/http/method.go:12

const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH" // RFC 5789
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	Meth...

Common HTTP methods. Unless otherwise noted, these are defined in RFC 7231 section 4.3.

net/http/method.go:18

const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH" // RFC 5789
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	Meth...

Common HTTP methods. Unless otherwise noted, these are defined in RFC 7231 section 4.3.

net/http/method.go:15

const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH" // RFC 5789
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	Meth...

Common HTTP methods. Unless otherwise noted, these are defined in RFC 7231 section 4.3.

net/http/method.go:13

const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH" // RFC 5789
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	Meth...

Common HTTP methods. Unless otherwise noted, these are defined in RFC 7231 section 4.3.

net/http/method.go:14

const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH" // RFC 5789
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	Meth...

Common HTTP methods. Unless otherwise noted, these are defined in RFC 7231 section 4.3.

net/http/method.go:19

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:17

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:23

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:68

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:36

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:45

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:10

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:16

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:13

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:53

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:58

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:39

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:28

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:70

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:46

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:71

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:24

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:73

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:66

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:47

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:57

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:74

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:41

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:55

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:27

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:26

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:22

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:76

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:19

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:18

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:42

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:75

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:40

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:67

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:30

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:15

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:21

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:38

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:34

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:48

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:61

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:12

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:43

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:52

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:49

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:63

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:44

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:50

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:20

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:29

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:69

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:11

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:54

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:33

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:59

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:62

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:37

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:64

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:56

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:51

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:60

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:31

const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // ...

HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

net/http/status.go:72

const TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"

TimeFormat is the time format to use when generating times in HTTP headers. It is like [time.RFC1123] but hard-codes GMT as the time zone. The time being formatted must be in UTC for Format to generate the correct format. For parsing this time format, see [ParseTime].

net/http/server.go:971

const TrailerPrefix = "Trailer:"

TrailerPrefix is a magic prefix for [ResponseWriter.Header] map keys that, if present, signals that the map entry is actually for the response trailers, and not the response headers. The prefix is stripped after the ServeHTTP call finishes and the values are sent in the trailers. This mechanism is intended only for trailers that are not known prior to the headers being written. If the set of trailers is fixed or known before the header is written, the normal Go trailers mechanism is preferre...

net/http/server.go:525

Variables

var DefaultClient = &Client{}

DefaultClient is the default [Client] and is used by [Get], [Head], and [Post].

net/http/client.go:109

var DefaultServeMux = &defaultServeMux

DefaultServeMux is the default [ServeMux] used by [Serve].

net/http/server.go:2588

var ErrAbortHandler = errors.New("net/http: abort Handler")

ErrAbortHandler is a sentinel panic value to abort a handler. While any panic from ServeHTTP aborts the response to the client, panicking with ErrAbortHandler also suppresses logging of a stack trace to the server's error log.

net/http/server.go:1873

var (
	// ErrBodyNotAllowed is returned by ResponseWriter.Write calls
	// when the HTTP method or response code does not permit a
	// body.
	ErrBodyNotAllowed = errors.New("http: request method or ...

Errors used by the HTTP server.

net/http/server.go:43

var ErrBodyReadAfterClose = errors.New("http: invalid Read on closed Body")

ErrBodyReadAfterClose is returned when reading a [Request] or [Response] Body after the body has been closed. This typically happens when the body is read after an HTTP [Handler] calls WriteHeader or Write on its [ResponseWriter].

net/http/transfer.go:829

var (
	// ErrBodyNotAllowed is returned by ResponseWriter.Write calls
	// when the HTTP method or response code does not permit a
	// body.
	ErrBodyNotAllowed = errors.New("http: request method or ...

Errors used by the HTTP server.

net/http/server.go:56

var ErrHandlerTimeout = errors.New("http: Handler timeout")

ErrHandlerTimeout is returned on [ResponseWriter] Write calls in handlers which have timed out.

net/http/server.go:3797

var (
	// ErrNotSupported indicates that a feature is not supported.
	//
	// It is returned by ResponseController methods to indicate that
	// the handler does not support the method, and by the Pu...

net/http/request.go:83

var (
	// ErrBodyNotAllowed is returned by ResponseWriter.Write calls
	// when the HTTP method or response code does not permit a
	// body.
	ErrBodyNotAllowed = errors.New("http: request method or ...

Errors used by the HTTP server.

net/http/server.go:50

var ErrLineTooLong = internal.ErrLineTooLong

ErrLineTooLong is returned when reading request or response bodies with malformed chunked encoding.

net/http/transfer.go:31

var (
	// ErrNotSupported indicates that a feature is not supported.
	//
	// It is returned by ResponseController methods to indicate that
	// the handler does not support the method, and by the Pu...

net/http/request.go:74

var (
	// ErrNotSupported indicates that a feature is not supported.
	//
	// It is returned by ResponseController methods to indicate that
	// the handler does not support the method, and by the Pu...

net/http/request.go:93

var ErrMissingFile = errors.New("http: no such file")

ErrMissingFile is returned by FormFile when the provided file field name is either not present in the request or not a file field.

net/http/request.go:41

var ErrNoCookie = errors.New("http: named cookie not present")

ErrNoCookie is returned by Request's Cookie method when a cookie is not found.

net/http/request.go:442

var ErrNoLocation = errors.New("http: no Location header in response")

ErrNoLocation is returned by the [Response.Location] method when no Location header is present.

net/http/response.go:131

var (
	// ErrNotSupported indicates that a feature is not supported.
	//
	// It is returned by ResponseController methods to indicate that
	// the handler does not support the method, and by the Pu...

net/http/request.go:78

var (
	// ErrNotSupported indicates that a feature is not supported.
	//
	// It is returned by ResponseController methods to indicate that
	// the handler does not support the method, and by the Pu...

net/http/request.go:65

var ErrSchemeMismatch = errors.New("http: server gave HTTP response to HTTPS client")

ErrSchemeMismatch is returned when a server returns an HTTP response to an HTTPS client.

net/http/client.go:212

var ErrServerClosed = errors.New("http: Server closed")

ErrServerClosed is returned by the [Server.Serve], [ServeTLS], [ListenAndServe], and [ListenAndServeTLS] methods after a call to [Server.Shutdown] or [Server.Close].

net/http/server.go:3392

var (
	// ErrNotSupported indicates that a feature is not supported.
	//
	// It is returned by ResponseController methods to indicate that
	// the handler does not support the method, and by the Pu...

net/http/request.go:88

var ErrSkipAltProtocol = errors.New("net/http: skip alternate protocol")

ErrSkipAltProtocol is a sentinel error value defined by Transport.RegisterProtocol.

net/http/transport.go:866

var (
	// ErrNotSupported indicates that a feature is not supported.
	//
	// It is returned by ResponseController methods to indicate that
	// the handler does not support the method, and by the Pu...

net/http/request.go:70

var ErrUseLastResponse = errors.New("net/http: use last response")

ErrUseLastResponse can be returned by Client.CheckRedirect hooks to control how redirects are processed. If returned, the next request is not sent and the most recent response is returned with its body unclosed.

net/http/client.go:498

var (
	// ErrBodyNotAllowed is returned by ResponseWriter.Write calls
	// when the HTTP method or response code does not permit a
	// body.
	ErrBodyNotAllowed = errors.New("http: request method or ...

Errors used by the HTTP server.

net/http/server.go:61

var (
	// ServerContextKey is a context key. It can be used in HTTP
	// handlers with Context.Value to access the server that
	// started the handler. The associated value will be of
	// type *Serv...

net/http/server.go:250

var NoBody = noBody{}

NoBody is an [io.ReadCloser] with no bytes. Read always returns EOF and Close always returns nil. It can be used in an outgoing client request to explicitly signal that a request has zero bytes. An alternative, however, is to simply set [Request.Body] to nil.

net/http/http.go:173

var (
	// ServerContextKey is a context key. It can be used in HTTP
	// handlers with Context.Value to access the server that
	// started the handler. The associated value will be of
	// type *Serv...

net/http/server.go:244

Functions

func AllowQuerySemicolons(h Handler) Handler

AllowQuerySemicolons returns a handler that serves requests by converting any unescaped semicolons in the URL query to ampersands, and invoking the handler h. This restores the pre-Go 1.17 behavior of splitting query parameters on both semicolons and ampersands. (See golang.org/issue/25192). Note that this behavior doesn't match that of many proxies, and the mismatch can lead to security issues. AllowQuerySemicolons should be invoked before [Request.ParseForm] is called.

net/http/server.go:3325

func CanonicalHeaderKey(s string) string

CanonicalHeaderKey returns the canonical format of the header key s. The canonicalization converts the first letter and any letter following a hyphen to upper case; the rest are converted to lowercase. For example, the canonical key for "accept-encoding" is "Accept-Encoding". If s contains a space or invalid header field bytes, it is returned without modifications.

net/http/header.go:234

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".

net/http/sniff.go:21

func Error(w ResponseWriter, error string, code int)

Error replies to the request with the specified error message and HTTP code. It does not otherwise end the request; the caller should ensure no further writes are done to w. The error message should be plain text. Error deletes the Content-Length header, sets Content-Type to “text/plain; charset=utf-8”, and sets X-Content-Type-Options to “nosniff”. This configures the header properly for the error message, in case the caller had set it up expecting a successful output.

net/http/server.go:2301

func FileServer(root FileSystem) Handler

FileServer returns a handler that serves HTTP requests with the contents of the file system rooted at root. As a special case, the returned file server redirects any request ending in "/index.html" to the same path, without the final "index.html". To use the operating system's file system implementation, use [http.Dir]: http.Handle("/", http.FileServer(http.Dir("/tmp"))) To use an [fs.FS] implementation, use [http.FileServerFS] instead.

net/http/fs.go:971

func FileServerFS(root fs.FS) Handler

FileServerFS returns a handler that serves HTTP requests with the contents of the file system fsys. The files provided by fsys must implement [io.Seeker]. As a special case, the returned file server redirects any request ending in "/index.html" to the same path, without the final "index.html". http.Handle("/", http.FileServerFS(fsys))

net/http/fs.go:984

func FS(fsys fs.FS) FileSystem

FS converts fsys to a [FileSystem] implementation, for use with [FileServer] and [NewFileTransport]. The files provided by fsys must implement [io.Seeker].

net/http/fs.go:954

func Get(url string) (*Response, error)

Get issues a GET to the specified URL. If the response is one of the following redirect codes, Get follows the redirect, up to a maximum of 10 redirects: 301 (Moved Permanently) 302 (Found) 303 (See Other) 307 (Temporary Redirect) 308 (Permanent Redirect) An error is returned if there were too many redirects or if there was an HTTP protocol error. A non-2xx response doesn't cause an error. Any returned error will be of type [*url.Error]. The url.Error value's Timeout method will report...

net/http/client.go:457

func Handle(pattern string, handler Handler)

Handle registers the handler for the given pattern in [DefaultServeMux]. The documentation for [ServeMux] explains how patterns are matched.

net/http/server.go:2862

func HandleFunc(pattern string, handler func(...))

HandleFunc registers the handler function for the given pattern in [DefaultServeMux]. The documentation for [ServeMux] explains how patterns are matched.

net/http/server.go:2872

func ListenAndServe(addr string, handler Handler) error

ListenAndServe listens on the TCP network address addr and then calls [Serve] with handler to handle requests on incoming connections. Accepted connections are configured to enable TCP keep-alives. The handler is typically nil, in which case [DefaultServeMux] is used. ListenAndServe always returns a non-nil error.

net/http/server.go:3673

func ListenAndServeTLS(addr string, certFile string, keyFile string, handler Handler) error

ListenAndServeTLS acts identically to [ListenAndServe], except that it expects HTTPS connections. Additionally, files containing a certificate and matching private key for the server must be provided. If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any intermediates, and the CA's certificate.

net/http/server.go:3683

func MaxBytesHandler(h Handler, n int64) Handler

MaxBytesHandler returns a [Handler] that runs h with its [ResponseWriter] and [Request.Body] wrapped by a MaxBytesReader.

net/http/server.go:4067

func MaxBytesReader(w ResponseWriter, r io.ReadCloser, n int64) io.ReadCloser

MaxBytesReader is similar to [io.LimitReader] but is intended for limiting the size of incoming request bodies. In contrast to io.LimitReader, MaxBytesReader's result is a ReadCloser, returns a non-nil error of type [*MaxBytesError] for a Read beyond the limit, and closes the underlying reader when its Close method is called. MaxBytesReader prevents clients from accidentally or maliciously sending a large request and wasting server resources. If possible, it tells the [ResponseWriter] to clo...

net/http/request.go:1186

func NewCrossOriginProtection() *CrossOriginProtection

NewCrossOriginProtection returns a new [CrossOriginProtection] value.

net/http/csrf.go:44

func NewFileTransport(fs FileSystem) RoundTripper

NewFileTransport returns a new [RoundTripper], serving the provided [FileSystem]. The returned RoundTripper ignores the URL host in its incoming requests, as well as most other properties of the request. The typical use case for NewFileTransport is to register the "file" protocol with a [Transport], as in: t := &http.Transport{} t.RegisterProtocol("file", http.NewFileTransport(http.Dir("/"))) c := &http.Client{Transport: t} res, err := c.Get("file:///etc/passwd") ...

net/http/filetransport.go:31

func NewFileTransportFS(fsys fs.FS) RoundTripper

NewFileTransportFS returns a new [RoundTripper], serving the provided file system fsys. The returned RoundTripper ignores the URL host in its incoming requests, as well as most other properties of the request. The files provided by fsys must implement [io.Seeker]. The typical use case for NewFileTransportFS is to register the "file" protocol with a [Transport], as in: fsys := os.DirFS("/") t := &http.Transport{} t.RegisterProtocol("file", http.NewFileTransportFS(fsys)) c := &http.Client...

net/http/filetransport.go:49

func NewRequest(method string, url string, body io.Reader) (*Request, error)

NewRequest wraps [NewRequestWithContext] using [context.Background].

net/http/request.go:862

func NewRequestWithContext(ctx context.Context, method string, url string, body io.Reader) (*Request, error)

NewRequestWithContext returns a new [Request] given a method, URL, and optional body. If the provided body is also an [io.Closer], the returned [Request.Body] is set to body and will be closed (possibly asynchronously) by the Client methods Do, Post, and PostForm, and [Transport.RoundTrip]. NewRequestWithContext returns a Request suitable for use with [Client.Do] or [Transport.RoundTrip]. To create a request for use with testing a Server Handler, either use the [net/http/httptest.NewRequest...

net/http/request.go:889

func NewResponseController(rw ResponseWriter) *ResponseController

NewResponseController creates a [ResponseController] for a request. The ResponseWriter should be the original value passed to the [Handler.ServeHTTP] method, or have an Unwrap method returning the original ResponseWriter. If the ResponseWriter implements any of the following methods, the ResponseController will call them as appropriate: Flush() FlushError() error // alternative Flush returning an error Hijack() (net.Conn, *bufio.ReadWriter, error) SetReadDeadline(deadline time.Time) er...

net/http/responsecontroller.go:38

func NewServeMux() *ServeMux

NewServeMux allocates and returns a new [ServeMux].

net/http/server.go:2583

func NotFound(w ResponseWriter, r *Request)

NotFound replies to the request with an HTTP 404 not found error.

net/http/server.go:2322

func NotFoundHandler() Handler

NotFoundHandler returns a simple request handler that replies to each request with a “404 page not found” reply.

net/http/server.go:2326

func ParseCookie(line string) ([]*Cookie, error)

ParseCookie parses a Cookie header value and returns all the cookies which were set in it. Since the same cookie name can appear multiple times the returned Values can contain more than one value for a given key.

net/http/cookie.go:91

func ParseHTTPVersion(vers string) (int, bool)

ParseHTTPVersion parses an HTTP version string according to RFC 7230, section 2.6. "HTTP/1.0" returns (1, 0, true). Note that strings without a minor version, such as "HTTP/2", are not valid.

net/http/request.go:817

func ParseSetCookie(line string) (*Cookie, error)

ParseSetCookie parses a Set-Cookie header value and returns a cookie. It returns an error on syntax error.

net/http/cookie.go:120

func ParseTime(text string) (time.Time, error)

ParseTime parses a time header (such as the Date: header), trying each of the three formats allowed by HTTP/1.1: [TimeFormat], [time.RFC850], and [time.ANSIC].

net/http/header.go:129

func Post(url string, contentType string, body io.Reader) (*Response, error)

Post issues a POST to the specified URL. Caller should close resp.Body when done reading from it. If the provided body is an [io.Closer], it is closed after the request. Post is a wrapper around DefaultClient.Post. To set custom headers, use [NewRequest] and DefaultClient.Do. See the [Client.Do] method documentation for details on how redirects are handled. To make a request with a specified context.Context, use [NewRequestWithContext] and DefaultClient.Do.

net/http/client.go:856

func PostForm(url string, data url.Values) (*Response, error)

PostForm issues a POST to the specified URL, with data's keys and values URL-encoded as the request body. The Content-Type header is set to application/x-www-form-urlencoded. To set other headers, use [NewRequest] and DefaultClient.Do. When err is nil, resp always contains a non-nil resp.Body. Caller should close resp.Body when done reading from it. PostForm is a wrapper around DefaultClient.PostForm. See the [Client.Do] method documentation for details on how redirects are handled. To m...

net/http/client.go:899

func ProxyFromEnvironment(req *Request) (*url.URL, error)

ProxyFromEnvironment returns the URL of the proxy to use for a given request, as indicated by the environment variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY (or the lowercase versions thereof). Requests use the proxy from the environment variable matching their scheme, unless excluded by NO_PROXY. The environment values may be either a complete URL or a "host[:port]", in which case the "http" scheme is assumed. An error is returned if the value is a different form. A nil URL and nil error a...

net/http/transport.go:507

func ProxyURL(fixedURL *url.URL) func(...)

ProxyURL returns a proxy function (for use in a [Transport]) that always returns the same URL.

net/http/transport.go:513

func ReadRequest(b *bufio.Reader) (*Request, error)

ReadRequest reads and parses an incoming request from b. ReadRequest is a low-level function and should only be used for specialized applications; most code should use the [Server] to read requests and handle them via the [Handler] interface. ReadRequest only supports HTTP/1.x requests. For HTTP/2, use golang.org/x/net/http2.

net/http/request.go:1058

func ReadResponse(r *bufio.Reader, req *Request) (*Response, error)

ReadResponse reads and returns an HTTP response from r. The req parameter optionally specifies the [Request] that corresponds to this [Response]. If nil, a GET request is assumed. Clients must call resp.Body.Close when finished reading resp.Body. After that call, clients can inspect resp.Trailer to find key/value pairs included in the response trailer.

net/http/response.go:154

func Redirect(w ResponseWriter, r *Request, url string, code int)

Redirect replies to the request with a redirect to url, which may be a path relative to the request path. Any non-ASCII characters in url will be percent-encoded, but existing percent encodings will not be changed. The provided code should be in the 3xx range and is usually [StatusMovedPermanently], [StatusFound] or [StatusSeeOther]. If the Content-Type header has not been set, [Redirect] sets it to "text/html; charset=utf-8" and writes a small HTML body. Setting the Content-Type header to ...

net/http/server.go:2367

func RedirectHandler(url string, code int) Handler

RedirectHandler returns a request handler that redirects each request it receives to the given url using the given status code. The provided code should be in the 3xx range and is usually [StatusMovedPermanently], [StatusFound] or [StatusSeeOther].

net/http/server.go:2452

func Serve(l net.Listener, handler Handler) error

Serve accepts incoming HTTP connections on the listener l, creating a new service goroutine for each. The service goroutines read requests and then call handler to reply to them. The handler is typically nil, in which case [DefaultServeMux] is used. HTTP/2 support is only enabled if the Listener returns [*tls.Conn] connections and they were configured with "h2" in the TLS Config.NextProtos. Serve always returns a non-nil error.

net/http/server.go:2940

func ServeContent(w ResponseWriter, req *Request, name string, modtime time.Time, content io.ReadSeeker)

ServeContent replies to the request using the content in the provided ReadSeeker. The main benefit of ServeContent over [io.Copy] is that it handles Range requests properly, sets the MIME type, and handles If-Match, If-Unmodified-Since, If-None-Match, If-Modified-Since, and If-Range requests. If the response's Content-Type header is not set, ServeContent first tries to deduce the type from name's file extension and, if that fails, falls back to reading the first block of the content and pass...

net/http/fs.go:245

func ServeFile(w ResponseWriter, r *Request, name string)

ServeFile replies to the request with the contents of the named file or directory. If the provided file or directory name is a relative path, it is interpreted relative to the current directory and may ascend to parent directories. If the provided name is constructed from user input, it should be sanitized before calling [ServeFile]. As a precaution, ServeFile will reject requests where r.URL.Path contains a ".." path element; this protects against callers who might unsafely use [filepath.J...

net/http/fs.go:814

func ServeFileFS(w ResponseWriter, r *Request, fsys fs.FS, name string)

ServeFileFS replies to the request with the contents of the named file or directory from the file system fsys. The files provided by fsys must implement [io.Seeker]. If the provided name is constructed from user input, it should be sanitized before calling [ServeFileFS]. As a precaution, ServeFileFS will reject requests where r.URL.Path contains a ".." path element; this protects against callers who might unsafely use [filepath.Join] on r.URL.Path without sanitizing it and then use that fil...

net/http/fs.go:848

func ServeTLS(l net.Listener, handler Handler, certFile string, keyFile string) error

ServeTLS accepts incoming HTTPS connections on the listener l, creating a new service goroutine for each. The service goroutines read requests and then call handler to reply to them. The handler is typically nil, in which case [DefaultServeMux] is used. Additionally, files containing a certificate and matching private key for the server must be provided. If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any interme...

net/http/server.go:2957

func SetCookie(w ResponseWriter, cookie *Cookie)

SetCookie adds a Set-Cookie header to the provided [ResponseWriter]'s headers. The provided cookie must have a valid Name. Invalid cookies may be silently dropped.

net/http/cookie.go:251

func StatusText(code int) string

StatusText returns a text for the HTTP status code. It returns the empty string if the code is unknown.

net/http/status.go:81

func StripPrefix(prefix string, h Handler) Handler

StripPrefix returns a handler that serves HTTP requests by removing the given prefix from the request URL's Path (and RawPath if set) and invoking the handler h. StripPrefix handles a request for a path that doesn't begin with prefix by replying with an HTTP 404 not found error. The prefix must match exactly: if the prefix in the request contains escaped characters the reply is also an HTTP 404 not found error.

net/http/server.go:2334

func TimeoutHandler(h Handler, dt time.Duration, msg string) Handler

TimeoutHandler returns a [Handler] that runs h with the given time limit. The new Handler calls h.ServeHTTP to handle each request, but if a call runs for longer than its time limit, the handler responds with a 503 Service Unavailable error and the given message in its body. (If msg is empty, a suitable default message will be sent.) After such a timeout, writes by h to its [ResponseWriter] will return [ErrHandlerTimeout]. TimeoutHandler supports the [Pusher] interface but does not support ...

net/http/server.go:3787

Types

type Client struct {
	// Transport specifies the mechanism by which individual
	// HTTP requests are made.
	// If nil, DefaultTransport is used.
	Transport RoundTripper

	// CheckRedirect specifies...

A Client is an HTTP client. Its zero value ([DefaultClient]) is a usable client that uses [DefaultTransport]. The [Client.Transport] typically has internal state (cached TCP connections), so Clients should be reused instead of created as needed. Clients are safe for concurrent use by multiple goroutines. A Client is higher-level than a [RoundTripper] (such as [Transport]) and additionally handles HTTP details such as cookies and redirects. When following redirects, the Client will forward ...

net/http/client.go:57

func (c *Client) CloseIdleConnections()

CloseIdleConnections closes any connections on its [Transport] which were previously connected from previous requests but are now sitting idle in a "keep-alive" state. It does not interrupt any connections currently in use. If [Client.Transport] does not have a [Client.CloseIdleConnections] method then this method does nothing.

net/http/client.go:966

func (c *Client) Do(req *Request) (*Response, error)

Do sends an HTTP request and returns an HTTP response, following policy (such as redirects, cookies, auth) as configured on the client. An error is returned if caused by client policy (such as CheckRedirect), or failure to speak HTTP (such as a network connectivity problem). A non-2xx status code doesn't cause an error. If the returned error is nil, the [Response] will contain a non-nil Body which the user is expected to close. If the Body is not both read to EOF and closed, the [Client]'s ...

net/http/client.go:591

func (c *Client) Get(url string) (*Response, error)

Get issues a GET to the specified URL. If the response is one of the following redirect codes, Get follows the redirect after calling the [Client.CheckRedirect] function: 301 (Moved Permanently) 302 (Found) 303 (See Other) 307 (Temporary Redirect) 308 (Permanent Redirect) An error is returned if the [Client.CheckRedirect] function fails or if there was an HTTP protocol error. A non-2xx response doesn't cause an error. Any returned error will be of type [*url.Error]. The url.Error value...

net/http/client.go:484

func (c *Client) Post(url string, contentType string, body io.Reader) (*Response, error)

Post issues a POST to the specified URL. Caller should close resp.Body when done reading from it. If the provided body is an [io.Closer], it is closed after the request. To set custom headers, use [NewRequest] and [Client.Do]. To make a request with a specified context.Context, use [NewRequestWithContext] and [Client.Do]. See the [Client.Do] method documentation for details on how redirects are handled.

net/http/client.go:874

func (c *Client) PostForm(url string, data url.Values) (*Response, error)

PostForm issues a POST to the specified URL, with data's keys and values URL-encoded as the request body. The Content-Type header is set to application/x-www-form-urlencoded. To set other headers, use [NewRequest] and [Client.Do]. When err is nil, resp always contains a non-nil resp.Body. Caller should close resp.Body when done reading from it. See the [Client.Do] method documentation for details on how redirects are handled. To make a request with a specified context.Context, use [NewReq...

net/http/client.go:917

type ClientConn struct {
	// contains filtered or unexported fields
}

A ClientConn is a client connection to an HTTP server. Unlike a [Transport], a ClientConn represents a single connection. Most users should use a Transport rather than creating client connections directly.

net/http/clientconn.go:21

func (cc *ClientConn) Available() int

Available reports the number of requests that may be sent to the connection without blocking. It returns 0 if the connection is closed.

net/http/clientconn.go:258

func (cc *ClientConn) Close() error

Close closes the connection. Outstanding RoundTrip calls are interrupted.

net/http/clientconn.go:202

func (cc *ClientConn) Err() error

Err reports any fatal connection errors. It returns nil if the connection is usable. If it returns non-nil, the connection can no longer be used.

net/http/clientconn.go:210

func (cc *ClientConn) InFlight() int

InFlight reports the number of requests in flight, including reserved requests. It returns 0 if the connection is closed.

net/http/clientconn.go:265

func (cc *ClientConn) Release()

Release releases an unused concurrency slot reserved by Reserve. If there are no reserved concurrency slots, it has no effect.

net/http/clientconn.go:289

func (cc *ClientConn) Reserve() error

Reserve reserves a concurrency slot on the connection. If Reserve returns nil, one additional RoundTrip call may be made without waiting for an existing request to complete. The reserved concurrency slot is accounted as an in-flight request. A successful call to RoundTrip will decrement the Available count and increment the InFlight count. Each successful call to Reserve should be followed by exactly one call to RoundTrip or Release, which will consume or release the reservation. If the co...

net/http/clientconn.go:282

func (cc *ClientConn) RoundTrip(req *Request) (*Response, error)

RoundTrip implements the [RoundTripper] interface. The request is sent on the client connection, regardless of the URL being requested or any proxy settings. If the connection is at its concurrency limit, RoundTrip waits for the connection to become available before sending the request.

net/http/clientconn.go:246

func (cc *ClientConn) SetStateHook(f func(...))

SetStateHook arranges for f to be called when the state of the connection changes. At most one call to f is made at a time. If the connection's state has changed since it was created, f is called immediately in a separate goroutine. f may be called synchronously from RoundTrip or Response.Body.Close. If SetStateHook is called multiple times, the new hook replaces the old one. If f is nil, no further calls will be made to f after SetStateHook returns. f is called when Available increases (mo...

net/http/clientconn.go:366

type CloseNotifier interface {
	// CloseNotify returns a channel that receives at most a
	// single value (true) when the client connection has gone
	// away.
	//
	// CloseNotify may wait to notify...

The CloseNotifier interface is implemented by ResponseWriters which allow detecting when the underlying connection has gone away. This mechanism can be used to cancel long operations on the server if the client has disconnected before the response is ready. Deprecated: the CloseNotifier interface predates Go's context package. New code should use [Request.Context] instead.

net/http/server.go:217

type ConnState int

A ConnState represents the state of a client connection to a server. It's used by the optional [Server.ConnState] hook.

net/http/server.go:3237

func (c ConnState) String() string

net/http/server.go:3283

func (c *Cookie) String() string

String returns the serialization of the cookie for use in a [Cookie] header (if only Name and Value are set) or a Set-Cookie response header (if other fields are set). If c is nil or c.Name is invalid, the empty string is returned.

net/http/cookie.go:261

func (c *Cookie) Valid() error

Valid reports whether the cookie is valid.

net/http/cookie.go:328

type CookieJar interface {
	// SetCookies handles the receipt of the cookies in a reply for the
	// given URL.  It may or may not choose to save the cookies, depending
	// on the jar's policy and i...

A CookieJar manages storage and use of cookies in HTTP requests. Implementations of CookieJar must be safe for concurrent use by multiple goroutines. The net/http/cookiejar package provides a CookieJar implementation.

net/http/jar.go:17

type CrossOriginProtection struct {
	// contains filtered or unexported fields
}

CrossOriginProtection implements protections against [Cross-Site Request Forgery (CSRF)] by rejecting non-safe cross-origin browser requests. Cross-origin requests are currently detected with the [Sec-Fetch-Site] header, available in all browsers since 2023, or by comparing the hostname of the [Origin] header with the Host header. The GET, HEAD, and OPTIONS methods are [safe methods] and are always allowed. It's important that applications do not perform any state changing actions due to re...

net/http/csrf.go:36

func (c *CrossOriginProtection) AddInsecureBypassPattern(pattern string)

AddInsecureBypassPattern permits all requests that match the given pattern. The pattern syntax and precedence rules are the same as [ServeMux]. Only requests that match the pattern directly are permitted. Those that ServeMux would redirect to a pattern (e.g. after cleaning the path or adding a trailing slash) are not. AddInsecureBypassPattern panics if the pattern conflicts with one already registered, or if the pattern is syntactically invalid (for example, an improperly formed wildcard). ...

net/http/csrf.go:99

func (c *CrossOriginProtection) AddTrustedOrigin(origin string) error

AddTrustedOrigin allows all requests with an [Origin] header which exactly matches the given value. Origin header values are of the form "scheme://host[:port]". AddTrustedOrigin can be called concurrently with other methods or request handling, and applies to future requests. [Origin]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin

net/http/csrf.go:57

func (c *CrossOriginProtection) Check(req *Request) error

Check applies cross-origin checks to a request. It returns an error if the request should be rejected.

net/http/csrf.go:134

func (c *CrossOriginProtection) Handler(h Handler) Handler

Handler returns a handler that applies cross-origin checks before invoking the handler h. If a request fails cross-origin checks, the request is rejected with a 403 Forbidden status or handled with the handler passed to [CrossOriginProtection.SetDenyHandler].

net/http/csrf.go:206

func (c *CrossOriginProtection) SetDenyHandler(h Handler)

SetDenyHandler sets a handler to invoke when a request is rejected. The default error handler responds with a 403 Forbidden status. SetDenyHandler can be called concurrently with other methods or request handling, and applies to future requests. Check does not call the error handler.

net/http/csrf.go:124

type Dir string

A Dir implements [FileSystem] using the native file system restricted to a specific directory tree. While the [FileSystem.Open] method takes '/'-separated paths, a Dir's string value is a directory path on the native file system, not a URL, so it is separated by [filepath.Separator], which isn't necessarily '/'. Note that Dir could expose sensitive files and directories. Dir will follow symlinks pointing out of the directory tree, which can be especially dangerous if serving from a director...

net/http/fs.go:44

func (d Dir) Open(name string) (File, error)

Open implements [FileSystem] using [os.Open], opening files for reading rooted and relative to the directory d.

net/http/fs.go:77

type File interface {
	io.Closer
	io.Reader
	io.Seeker
	Readdir(count int) ([]fs.FileInfo, error)
	Stat() (fs.FileInfo, error)
}

A File is returned by a [FileSystem]'s Open method and can be served by the [FileServer] implementation. The methods should behave the same as those on an [*os.File].

net/http/fs.go:113

type FileSystem interface {
	Open(name string) (File, error)
}

A FileSystem implements access to a collection of named files. The elements in a file path are separated by slash ('/', U+002F) characters, regardless of host operating system convention. See the [FileServer] function to convert a FileSystem to a [Handler]. This interface predates the [fs.FS] interface, which can be used instead: the [FS] adapter function converts an fs.FS to a FileSystem.

net/http/fs.go:105

type Flusher interface {
	// Flush sends any buffered data to the client.
	Flush()
}

The Flusher interface is implemented by ResponseWriters that allow an HTTP handler to flush buffered data to the client. The default HTTP/1.x and HTTP/2 [ResponseWriter] implementations support [Flusher], but ResponseWriter wrappers may not. Handlers should always test for this ability at runtime. Note that even for ResponseWriters that support Flush, if the client is connected through an HTTP proxy, the buffered data may not reach the client until the response completes.

net/http/server.go:174

type Handler interface {
	ServeHTTP(ResponseWriter, *Request)
}

A Handler responds to an HTTP request. [Handler.ServeHTTP] should write reply headers and data to the [ResponseWriter] and then return. Returning signals that the request is finished; it is not valid to use the [ResponseWriter] or read from the [Request.Body] after or concurrently with the completion of the ServeHTTP call. Depending on the HTTP client software, HTTP protocol version, and any intermediaries between the client and the Go server, it may not be possible to read from the [Reques...

net/http/server.go:88

type HandlerFunc func(ResponseWriter, *Request)

The HandlerFunc type is an adapter to allow the use of ordinary functions as HTTP handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a [Handler] that calls f.

net/http/server.go:2282

func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request)

ServeHTTP calls f(w, r).

net/http/server.go:2285

func (h Header) Add(key string, value string)

Add adds the key, value pair to the header. It appends to any existing values associated with key. The key is case insensitive; it is canonicalized by [CanonicalHeaderKey].

net/http/header.go:30

func (h Header) Clone() Header

Clone returns a copy of h or nil if h is nil.

net/http/header.go:94

func (h Header) Del(key string)

Del deletes the values associated with key. The key is case insensitive; it is canonicalized by [CanonicalHeaderKey].

net/http/header.go:80

func (h Header) Get(key string) string

Get gets the first value associated with the given key. If there are no values associated with the key, Get returns "". It is case insensitive; [textproto.CanonicalMIMEHeaderKey] is used to canonicalize the provided key. Get assumes that all keys are stored in canonical form. To use non-canonical keys, access the map directly.

net/http/header.go:49

func (h Header) Set(key string, value string)

Set sets the header entries associated with key to the single element value. It replaces any existing values associated with key. The key is case insensitive; it is canonicalized by [textproto.CanonicalMIMEHeaderKey]. To use non-canonical keys, assign to the map directly.

net/http/header.go:39

func (h Header) Values(key string) []string

Values returns all values associated with the given key. It is case insensitive; [textproto.CanonicalMIMEHeaderKey] is used to canonicalize the provided key. To use non-canonical keys, access the map directly. The returned slice is not a copy.

net/http/header.go:58

func (h Header) Write(w io.Writer) error

Write writes a header in wire format.

net/http/header.go:85

func (h Header) WriteSubset(w io.Writer, exclude map[string]bool) error

WriteSubset writes a header in wire format. If exclude is not nil, keys where exclude[key] == true are not written. Keys are not canonicalized before checking the exclude map.

net/http/header.go:186

type Hijacker interface {
	// Hijack lets the caller take over the connection.
	// After a call to Hijack the HTTP server library
	// will not do anything else with the connection.
	//
	// It becom...

The Hijacker interface is implemented by ResponseWriters that allow an HTTP handler to take over the connection. The default [ResponseWriter] for HTTP/1.x connections supports Hijacker, but HTTP/2 connections intentionally do not. ResponseWriter wrappers may also not support Hijacker. Handlers should always test for this ability at runtime.

net/http/server.go:186

type HTTP2Config struct {
	// MaxConcurrentStreams optionally specifies the number of
	// concurrent streams that a client may have open at a time.
	// If zero, MaxConcurrentStreams defaults to at ...

HTTP2Config defines HTTP/2 configuration parameters common to both [Transport] and [Server].

net/http/http.go:232

type MaxBytesError struct {
	Limit int64
}

MaxBytesError is returned by [MaxBytesReader] when its read limit is exceeded.

net/http/request.go:1194

func (e *MaxBytesError) Error() string

net/http/request.go:1198

type ProtocolError struct {
	ErrorString string
}

ProtocolError represents an HTTP protocol error. Deprecated: Not all errors in the http package related to protocol errors are of type ProtocolError.

net/http/request.go:47

func (pe *ProtocolError) Error() string

net/http/request.go:51

func (pe *ProtocolError) Is(err error) bool

Is lets http.ErrNotSupported match errors.ErrUnsupported.

net/http/request.go:54

type Protocols struct {
	// contains filtered or unexported fields
}

Protocols is a set of HTTP protocols. The zero value is an empty set of protocols. The supported protocols are: - HTTP1 is the HTTP/1.0 and HTTP/1.1 protocols. HTTP1 is supported on both unsecured TCP and secured TLS connections. - HTTP2 is the HTTP/2 protcol over a TLS connection. - UnencryptedHTTP2 is the HTTP/2 protocol over an unsecured TCP connection.

net/http/http.go:30

func (p Protocols) HTTP1() bool

HTTP1 reports whether p includes HTTP/1.

net/http/http.go:41

func (p Protocols) HTTP2() bool

HTTP2 reports whether p includes HTTP/2.

net/http/http.go:47

func (p *Protocols) SetHTTP1(ok bool)

SetHTTP1 adds or removes HTTP/1 from p.

net/http/http.go:44

func (p *Protocols) SetHTTP2(ok bool)

SetHTTP2 adds or removes HTTP/2 from p.

net/http/http.go:50

func (p *Protocols) SetUnencryptedHTTP2(ok bool)

SetUnencryptedHTTP2 adds or removes unencrypted HTTP/2 from p.

net/http/http.go:56

func (p Protocols) String() string

net/http/http.go:66

func (p Protocols) UnencryptedHTTP2() bool

UnencryptedHTTP2 reports whether p includes unencrypted HTTP/2.

net/http/http.go:53

type Pusher interface {
	// Push initiates an HTTP/2 server push. This constructs a synthetic
	// request using the given target and options, serializes that request
	// into a PUSH_PROMISE frame, ...

Pusher is the interface implemented by ResponseWriters that support HTTP/2 server push. For more background, see https://tools.ietf.org/html/rfc7540#section-8.2.

net/http/http.go:202

type PushOptions struct {
	// Method specifies the HTTP method for the promised request.
	// If set, it must be "GET" or "HEAD". Empty means "GET".
	Method string

	// Header specifies additional p...

PushOptions describes options for [Pusher.Push].

net/http/http.go:188

type Request struct {
	// Method specifies the HTTP method (GET, POST, PUT, etc.).
	// For client requests, an empty string means GET.
	Method string

	// URL specifies either the URI being request...

A Request represents an HTTP request received by a server or to be sent by a client. The field semantics differ slightly between client and server usage. In addition to the notes on the fields below, see the documentation for [Request.Write] and [RoundTripper].

net/http/request.go:113

func (r *Request) AddCookie(c *Cookie)

AddCookie adds a cookie to the request. Per RFC 6265 section 5.4, AddCookie does not attach more than one [Cookie] header field. That means all cookies, if any, are written into the same line, separated by semicolon. AddCookie only sanitizes c's name and value, and does not sanitize a Cookie header already present in the request.

net/http/request.go:464

func (r *Request) BasicAuth() (string, bool)

BasicAuth returns the username and password provided in the request's Authorization header, if the request uses HTTP Basic Authentication. See RFC 2617, Section 2.

net/http/request.go:973

func (r *Request) Clone(ctx context.Context) *Request

Clone returns a deep copy of r with its context changed to ctx. The provided ctx must be non-nil. Clone only makes a shallow copy of the Body field. For an outgoing client request, the context controls the entire lifetime of a request and its response: obtaining a connection, sending the request, and reading the response headers and body.

net/http/request.go:386

func (r *Request) Context() context.Context

Context returns the request's context. To change the context, use [Request.Clone] or [Request.WithContext]. The returned context is always non-nil; it defaults to the background context. For outgoing client requests, the context controls cancellation. For incoming server requests, the context is canceled when the client's connection closes, the request is canceled (with HTTP/2), or when the ServeHTTP method returns.

net/http/request.go:352

func (r *Request) Cookies() []*Cookie

Cookies parses and returns the HTTP cookies sent with the request.

net/http/request.go:428

func (r *Request) CookiesNamed(name string) []*Cookie

CookiesNamed parses and returns the named HTTP cookies sent with the request or an empty slice if none matched.

net/http/request.go:434

func (r *Request) FormFile(key string) (multipart.File, *multipart.FileHeader, error)

FormFile returns the first file for the provided form key. FormFile calls [Request.ParseMultipartForm] and [Request.ParseForm] if necessary.

net/http/request.go:1446

func (r *Request) FormValue(key string) string

FormValue returns the first value for the named component of the query. The precedence order: 1. application/x-www-form-urlencoded form body (POST, PUT, PATCH only) 2. query parameters (always) 3. multipart/form-data form body (always) FormValue calls [Request.ParseMultipartForm] and [Request.ParseForm] if necessary and ignores any errors returned by these functions. If key is not present, FormValue returns the empty string. To access multiple values of the same key, call ParseForm and th...

net/http/request.go:1419

func (r *Request) MultipartReader() (*multipart.Reader, error)

MultipartReader returns a MIME multipart reader if this is a multipart/form-data or a multipart/mixed POST request, else returns nil and an error. Use this function instead of [Request.ParseMultipartForm] to process the request body as a stream.

net/http/request.go:497

func (r *Request) ParseForm() error

ParseForm populates r.Form and r.PostForm. For all requests, ParseForm parses the raw query from the URL and updates r.Form. For POST, PUT, and PATCH requests, it also reads the request body, parses it as a form and puts the results into both r.PostForm and r.Form. Request body parameters take precedence over URL query string values in r.Form. If the request Body's size has not already been limited by [MaxBytesReader], the size is capped at 10MB. For other HTTP methods, or when the Conten...

net/http/request.go:1327

func (r *Request) ParseMultipartForm(maxMemory int64) error

ParseMultipartForm parses a request body as multipart/form-data. The whole request body is parsed and up to a total of maxMemory bytes of its file parts are stored in memory, with the remainder stored on disk in temporary files. ParseMultipartForm calls [Request.ParseForm] if necessary. If ParseForm returns an error, ParseMultipartForm returns it but also continues parsing the request body. After one call to ParseMultipartForm, subsequent calls have no effect.

net/http/request.go:1370

func (r *Request) PathValue(name string) string

PathValue returns the value for the named path wildcard in the [ServeMux] pattern that matched the request. It returns the empty string if the request was not matched against a pattern or there is no such wildcard in the pattern.

net/http/request.go:1469

func (r *Request) PostFormValue(key string) string

PostFormValue returns the first value for the named component of the POST, PUT, or PATCH request body. URL query parameters are ignored. PostFormValue calls [Request.ParseMultipartForm] and [Request.ParseForm] if necessary and ignores any errors returned by these functions. If key is not present, PostFormValue returns the empty string.

net/http/request.go:1434

func (r *Request) ProtoAtLeast(major int, minor int) bool

ProtoAtLeast reports whether the HTTP protocol used in the request is at least major.minor.

net/http/request.go:417

func (r *Request) Referer() string

Referer returns the referring URL, if sent in the request. Referer is misspelled as in the request itself, a mistake from the earliest days of HTTP. This value can also be fetched from the [Header] map as Header["Referer"]; the benefit of making it available as a method is that the compiler can diagnose programs that use the alternate (correct English) spelling req.Referrer() but cannot diagnose programs that use Header["Referrer"].

net/http/request.go:481

func (r *Request) SetBasicAuth(username string, password string)

SetBasicAuth sets the request's Authorization header to use HTTP Basic Authentication with the provided username and password. With HTTP Basic Authentication the provided username and password are not encrypted. It should generally only be used in an HTTPS request. The username may not contain a colon. Some protocols may impose additional requirements on pre-escaping the username and password. For instance, when used with OAuth2, both arguments must be URL encoded first with [url.QueryEscape].

net/http/request.go:1022

func (r *Request) SetPathValue(name string, value string)

SetPathValue sets name to value, so that subsequent calls to r.PathValue(name) return value.

net/http/request.go:1478

func (r *Request) UserAgent() string

UserAgent returns the client's User-Agent, if sent in the request.

net/http/request.go:423

func (r *Request) WithContext(ctx context.Context) *Request

WithContext returns a shallow copy of r with its context changed to ctx. The provided ctx must be non-nil. For outgoing client request, the context controls the entire lifetime of a request and its response: obtaining a connection, sending the request, and reading the response headers and body. To create a new request with a context, use [NewRequestWithContext]. To make a deep copy of a request with a new context, use [Request.Clone].

net/http/request.go:368

func (r *Request) Write(w io.Writer) error

Write writes an HTTP/1.1 request, which is the header and body, in wire format. This method consults the following fields of the request: Host URL Method (defaults to "GET") Header ContentLength TransferEncoding Body If Body is present, Content-Length is <= 0 and [Request.TransferEncoding] hasn't been set to "identity", Write adds "Transfer-Encoding: chunked" to the header. Body is closed after it is sent.

net/http/request.go:561

func (r *Request) WriteProxy(w io.Writer) error

WriteProxy is like [Request.Write] but writes the request in the form expected by an HTTP proxy. In particular, [Request.WriteProxy] writes the initial Request-URI line of the request with an absolute URI, per section 5.3 of RFC 7230, including the scheme and host. In either case, WriteProxy also writes a Host header, using either r.Host or r.URL.Host.

net/http/request.go:571

type Response struct {
	Status     string // e.g. "200 OK"
	StatusCode int    // e.g. 200
	Proto      string // e.g. "HTTP/1.0"
	ProtoMajor int    // e.g. 1
	ProtoMinor int    // e.g. 0

	// Header...

Response represents the response from an HTTP request. The [Client] and [Transport] return Responses from servers once the response headers have been received. The response body is streamed on demand as the Body field is read.

net/http/response.go:35

func (r *Response) Cookies() []*Cookie

Cookies parses and returns the cookies set in the Set-Cookie headers.

net/http/response.go:125

func (r *Response) Location() (*url.URL, error)

Location returns the URL of the response's "Location" header, if present. Relative redirects are resolved relative to [Response.Request]. [ErrNoLocation] is returned if no Location header is present.

net/http/response.go:137

func (r *Response) ProtoAtLeast(major int, minor int) bool

ProtoAtLeast reports whether the HTTP protocol used in the response is at least major.minor.

net/http/response.go:224

func (r *Response) Write(w io.Writer) error

Write writes r to w in the HTTP/1.x server response format, including the status line, headers, body, and optional trailer. This method consults the following fields of the response r: StatusCode ProtoMajor ProtoMinor Request.Method TransferEncoding Trailer Body ContentLength Header, values for non-canonical keys will have unpredictable behavior The Response Body is closed after it is sent.

net/http/response.go:245

type ResponseController struct {
	// contains filtered or unexported fields
}

A ResponseController is used by an HTTP handler to control the response. A ResponseController may not be used after the [Handler.ServeHTTP] method has returned.

net/http/responsecontroller.go:17

func (c *ResponseController) EnableFullDuplex() error

EnableFullDuplex indicates that the request handler will interleave reads from [Request.Body] with writes to the [ResponseWriter]. For HTTP/1 requests, the Go HTTP server by default consumes any unread portion of the request body before beginning to write the response, preventing handlers from concurrently reading from the request and writing the response. Calling EnableFullDuplex disables this behavior and permits handlers to continue to read from the request while concurrently writing the ...

net/http/responsecontroller.go:129

func (c *ResponseController) Flush() error

Flush flushes buffered data to the client.

net/http/responsecontroller.go:47

func (c *ResponseController) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack lets the caller take over the connection. See the [Hijacker] interface for details.

net/http/responsecontroller.go:66

func (c *ResponseController) SetReadDeadline(deadline time.Time) error

SetReadDeadline sets the deadline for reading the entire request, including the body. Reads from the request body after the deadline has been exceeded will return an error. A zero value means no deadline. Setting the read deadline after it has been exceeded will not extend it.

net/http/responsecontroller.go:85

func (c *ResponseController) SetWriteDeadline(deadline time.Time) error

SetWriteDeadline sets the deadline for writing the response. Writes to the response body after the deadline has been exceeded will not block, but may succeed if the data has been buffered. A zero value means no deadline. Setting the write deadline after it has been exceeded will not extend it.

net/http/responsecontroller.go:105

type ResponseWriter interface {
	// Header returns the header map that will be sent by
	// [ResponseWriter.WriteHeader]. The [Header] map also is the mechanism with which
	// [Handler] implementati...

A ResponseWriter interface is used by an HTTP handler to construct an HTTP response. A ResponseWriter may not be used after [Handler.ServeHTTP] has returned.

net/http/server.go:96

type RoundTripper interface {
	// RoundTrip executes a single HTTP transaction, returning
	// a Response for the provided Request.
	//
	// RoundTrip should not attempt to interpret the response. In...

RoundTripper is an interface representing the ability to execute a single HTTP transaction, obtaining the [Response] for a given [Request]. A RoundTripper must be safe for concurrent use by multiple goroutines.

net/http/client.go:116

type SameSite int

SameSite allows a server to define a cookie attribute making it impossible for the browser to send this cookie along with cross-site requests. The main goal is to mitigate the risk of cross-origin information leakage, and provide some protection against cross-site request forgery attacks. See https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00 for details.

net/http/cookie.go:54

type ServeMux struct {
	// contains filtered or unexported fields
}

ServeMux is an HTTP request multiplexer. It matches the URL of each incoming request against a list of registered patterns and calls the handler for the pattern that most closely matches the URL. # Patterns Patterns can match the method, host and path of a request. Some examples: - "/index.html" matches the path "/index.html" for any host and method. - "GET /static/" matches a GET request whose path begins with "/static/". - "example.com/" matches any request to the host "example.com...

net/http/server.go:2575

func (mux *ServeMux) Handle(pattern string, handler Handler)

Handle registers the handler for the given pattern. If the given pattern conflicts with one that is already registered or if the pattern is invalid, Handle panics. See [ServeMux] for details on valid patterns and conflict rules.

net/http/server.go:2839

func (mux *ServeMux) HandleFunc(pattern string, handler func(...))

HandleFunc registers the handler function for the given pattern. If the given pattern conflicts with one that is already registered or if the pattern is invalid, HandleFunc panics. See [ServeMux] for details on valid patterns and conflict rules.

net/http/server.go:2852

func (mux *ServeMux) Handler(r *Request) (Handler, string)

Handler returns the handler to use for the given request, consulting r.Method, r.Host, and r.URL.Path. It always returns a non-nil handler. If the path is not in its canonical form, the handler will be an internally-generated handler that redirects to the canonical path. If the host contains a port, it is ignored when matching handlers. The path and host are used unchanged for CONNECT requests. Handler also returns the registered pattern that matches the request or, in the case of internall...

net/http/server.go:2647

func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request)

ServeHTTP dispatches the request to the handler whose pattern most closely matches the request URL.

net/http/server.go:2814

type Server struct {
	// Addr optionally specifies the TCP address for the server to listen on,
	// in the form "host:port". If empty, ":http" (port 80) is used.
	// The service names are defined i...

A Server defines parameters for running an HTTP server. The zero value for Server is a valid configuration.

net/http/server.go:2964

func (s *Server) Close() error

Close immediately closes all active net.Listeners and any connections in state [StateNew], [StateActive], or [StateIdle]. For a graceful shutdown, use [Server.Shutdown]. Close does not attempt to close (and does not even know about) any hijacked connections, such as WebSockets. Close returns any error returned from closing the [Server]'s underlying Listener(s).

net/http/server.go:3100

func (s *Server) ListenAndServe() error

ListenAndServe listens on the TCP network address s.Addr and then calls [Serve] to handle requests on incoming connections. Accepted connections are configured to enable TCP keep-alives. If s.Addr is blank, ":http" is used. ListenAndServe always returns a non-nil error. After [Server.Shutdown] or [Server.Close], the returned error is [ErrServerClosed].

net/http/server.go:3348

func (s *Server) ListenAndServeTLS(certFile string, keyFile string) error

ListenAndServeTLS listens on the TCP network address s.Addr and then calls [ServeTLS] to handle requests on incoming TLS connections. Accepted connections are configured to enable TCP keep-alives. Filenames containing a certificate and matching private key for the server must be provided if neither the [Server]'s TLSConfig.Certificates nor TLSConfig.GetCertificate are populated. If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's ...

net/http/server.go:3703

func (s *Server) RegisterOnShutdown(f func(...))

RegisterOnShutdown registers a function to call on [Server.Shutdown]. This can be used to gracefully shutdown connections that have undergone ALPN protocol upgrade or that have been hijacked. This function should start protocol-specific graceful shutdown, but should not wait for shutdown to complete.

net/http/server.go:3193

func (s *Server) Serve(l net.Listener) error

Serve accepts incoming connections on the Listener l, creating a new service goroutine for each. The service goroutines read requests and then call s.Handler to reply to them. HTTP/2 support is only enabled if the Listener returns [*tls.Conn] connections and they were configured with "h2" in the TLS Config.NextProtos. Serve always returns a non-nil error and closes l. After [Server.Shutdown] or [Server.Close], the returned error is [ErrServerClosed].

net/http/server.go:3404

func (s *Server) ServeTLS(l net.Listener, certFile string, keyFile string) error

ServeTLS accepts incoming connections on the Listener l, creating a new service goroutine for each. The service goroutines perform TLS setup and then read requests, calling s.Handler to reply to them. Files containing a certificate and matching private key for the server must be provided if neither the [Server]'s TLSConfig.Certificates, TLSConfig.GetCertificate nor config.GetConfigForClient are populated. If the certificate is signed by a certificate authority, the certFile should be the con...

net/http/server.go:3482

func (s *Server) SetKeepAlivesEnabled(v bool)

SetKeepAlivesEnabled controls whether HTTP keep-alives are enabled. By default, keep-alives are always enabled. Only very resource-constrained environments or servers in the process of shutting down should disable them.

net/http/server.go:3633

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server without interrupting any active connections. Shutdown works by first closing all open listeners, then closing all idle connections, and then waiting indefinitely for connections to return to idle and then shut down. If the provided context expires before the shutdown is complete, Shutdown returns the context's error, otherwise it returns any error returned from closing the [Server]'s underlying Listener(s). When Shutdown is called, [Serve], [ServeTLS...

net/http/server.go:3150

type Transport struct {

	// Proxy specifies a function to return a proxy for a given
	// Request. If the function returns a non-nil error, the
	// request is aborted with the provided error.
	//
	...

Transport is an implementation of [RoundTripper] that supports HTTP, HTTPS, and HTTP proxies (for either HTTP or HTTPS with CONNECT). By default, Transport caches connections for future re-use. This may leave many open connections when accessing many hosts. This behavior can be managed using [Transport.CloseIdleConnections] method and the [Transport.MaxIdleConnsPerHost] and [Transport.DisableKeepAlives] fields. Transports should be reused instead of created as needed. Transports are safe fo...

net/http/transport.go:97

func (t *Transport) CancelRequest(req *Request)

CancelRequest cancels an in-flight request by closing its connection. CancelRequest should only be called after [Transport.RoundTrip] has returned. Deprecated: Use [Request.WithContext] to create a request with a cancelable context instead. CancelRequest cannot cancel HTTP/2 requests. This may become a no-op in a future release of Go.

net/http/transport.go:951

func (t *Transport) Clone() *Transport

Clone returns a deep copy of t's exported fields.

net/http/transport.go:337

func (t *Transport) CloseIdleConnections()

CloseIdleConnections closes any connections which were previously connected from previous requests but are now sitting idle in a "keep-alive" state. It does not interrupt any connections currently in use.

net/http/transport.go:897

func (t *Transport) NewClientConn(ctx context.Context, scheme string, address string) (*ClientConn, error)

NewClientConn creates a new client connection to the given address. If scheme is "http", the connection is unencrypted. If scheme is "https", the connection uses TLS. The protocol used for the new connection is determined by the scheme, Transport.Protocols configuration field, and protocols supported by the server. See Transport.Protocols for more details. If Transport.Proxy is set and indicates that a request sent to the given address should use a proxy, the new connection uses that proxy...

net/http/clientconn.go:113

func (t *Transport) RegisterProtocol(scheme string, rt RoundTripper)

RegisterProtocol registers a new protocol with scheme. The [Transport] will pass requests using the given scheme to rt. It is rt's responsibility to simulate HTTP request semantics. RegisterProtocol can be used by other packages to provide implementations of protocol schemes like "ftp" or "file". If rt.RoundTrip returns [ErrSkipAltProtocol], the Transport will handle the [Transport.RoundTrip] itself for that one request, as if the protocol were not registered.

net/http/transport.go:878

func (t *Transport) RoundTrip(req *Request) (*Response, error)

RoundTrip implements the [RoundTripper] interface using the WHATWG Fetch API.

net/http/roundtrip_js.go:61