©
This document uses PHP Chinese website manual Release
import "net/http/internal"
概述
索引
包内部包含由net/http和net/http/httputil共享的HTTP内部消息。
变量
func NewChunkedReader(r io.Reader) io.Reader
func NewChunkedWriter(w io.Writer) io.WriteCloser
type FlushAfterChunkWriter
chunked.go testcert.go
var ErrLineTooLong = errors.New("header line too long")
LocalhostCert是一个PEM编码的TLS证书,其SAN IP为“127.0.0.1”和“:: 1”,将于1月29日16:00:00 2084 GMT到期。从src / crypto / tls生成:go run generate_cert.go --rsa-bits 1024 --host 127.0.0.1,:: 1,example.com --ca --start-date“Jan 1 00:00:00 1970 “--duration = 1000000h
var LocalhostCert = []byte(`-----BEGIN CERTIFICATE----- MIICEzCCAXygAwIBAgIQMIMChMLGrR+QvmQvpwAU6zANBgkqhkiG9w0BAQsFADAS MRAwDgYDVQQKEwdBY21lIENvMCAXDTcwMDEwMTAwMDAwMFoYDzIwODQwMTI5MTYw MDAwWjASMRAwDgYDVQQKEwdBY21lIENvMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB iQKBgQDuLnQAI3mDgey3VBzWnB2L39JUU4txjeVE6myuDqkM/uGlfjb9SjY1bIw4 iA5sBBZzHi3z0h1YV8QPuxEbi4nW91IJm2gsvvZhIrCHS3l6afab4pZBl2+XsDul rKBxKKtD1rGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTvqJQIDAQABo2gwZjAO BgNVHQ8BAf8EBAMCAqQwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUw AwEB/zAuBgNVHREEJzAlggtleGFtcGxlLmNvbYcEfwAAAYcQAAAAAAAAAAAAAAAA AAAAATANBgkqhkiG9w0BAQsFAAOBgQCEcetwO59EWk7WiJsG4x8SY+UIAA+flUI9 tyC4lNhbcF2Idq9greZwbYCqTTTr2XiRNSMLCOjKyI7ukPoPjo16ocHj+P3vZGfs h1fIw3cSS2OolhloGw/XM6RWPWtPAlGykKLciQrBru5NAPvCMsb/I1DAceTiotQM fblo6RBxUQ== -----END CERTIFICATE-----`)
LocalhostKey是localhostCert的私钥。
var LocalhostKey = []byte(`-----BEGIN RSA PRIVATE KEY----- MIICXgIBAAKBgQDuLnQAI3mDgey3VBzWnB2L39JUU4txjeVE6myuDqkM/uGlfjb9 SjY1bIw4iA5sBBZzHi3z0h1YV8QPuxEbi4nW91IJm2gsvvZhIrCHS3l6afab4pZB l2+XsDulrKBxKKtD1rGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTvqJQIDAQAB AoGAGRzwwir7XvBOAy5tM/uV6e+Zf6anZzus1s1Y1ClbjbE6HXbnWWF/wbZGOpet 3Zm4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKwZatTXtdZrhu+Jk7hx0nTPy8Jcb uJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+hgN4H qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprIMmPcQrooz8vp jy4SHEg1AkEA/v13/5M47K9vCxmb8QeD/asydfsgS5TeuNi8DoUBEmiSJwma7FXY fFUtxuvL7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su4b3sjXNueLKH85Q+phy2U fQtuUE9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xlp/DoCzjA0CQQDU y2ptGsuSmgUtWj3NM9xuwYPm+Z/F84K6+ARYiZ6PYj013sovGKUFfYAqVXVlxtIX qyUBnu3X9ps8ZfjLZO7BAkEAlT4R5Yl6cGhaJQYZHOde3JEMhNRcVFMO8dJDaFeo f9Oeos0UUothgiDktdQHxdNEwLjQf7lJJBzV+5OtwswCWA== -----END RSA PRIVATE KEY-----`)
func NewChunkedReader(r io.Reader) io.Reader
NewChunkedReader返回一个新的chunkedReader,它在返回之前将从r读出的数据转换成HTTP“chunked”格式。chunkedReader在读取最后的0长度块时返回io.EOF。
普通应用程序不需要NewChunkedReader。在阅读响应主体时,http包会自动解码分块。
func NewChunkedWriter(w io.Writer) io.WriteCloser
NewChunkedWriter返回一个新的chunkedWriter,在写入w之前将写入转换为HTTP“分块”格式。关闭返回的chunkedWriter将发送标记流结束的最终0长度块。
普通应用程序不需要NewChunkedWriter。如果处理程序未设置Content-Length标头,则http包会自动添加分块。在处理程序中使用newChunkedWriter会导致双重组块或使用Content-Length长度分块,这两者都是错误的。
FlushAfterChunkWriter从NewChunkedWriter的调用者发出信号,告知每个组块后面应该进行刷新。它由http.Transport代码用来保持头部和尾部的缓冲行为,但对于可能缓慢产生的请求体,在中间积极地清除块。见问题6574。
type FlushAfterChunkWriter struct { *bufio.Writer}