Source File
dump.go
Belonging Package
net/http/httputil
package httputil
import (
)
func ( io.ReadCloser) (, io.ReadCloser, error) {
type dumpConn struct {
io.Writer
io.Reader
}
func ( *dumpConn) () error { return nil }
func ( *dumpConn) () net.Addr { return nil }
func ( *dumpConn) () net.Addr { return nil }
func ( *dumpConn) ( time.Time) error { return nil }
func ( *dumpConn) ( time.Time) error { return nil }
func ( *dumpConn) ( time.Time) error { return nil }
type neverEnding byte
func ( neverEnding) ( []byte) ( int, error) {
for := range {
[] = byte()
}
return len(), nil
}
func ( *http.Request) int64 {
if .Body == nil || .Body == http.NoBody {
return 0
}
if .ContentLength != 0 {
return .ContentLength
}
return -1
}
go func() {
, := http.ReadRequest(bufio.NewReader())
:= .RequestURI
if == "" {
= .URL.RequestURI()
}
fmt.Fprintf(&, "%s %s HTTP/%d.%d\r\n", valueOrDefault(.Method, "GET"),
, .ProtoMajor, .ProtoMinor)
:= strings.HasPrefix(.RequestURI, "http://") || strings.HasPrefix(.RequestURI, "https://")
if ! {
:= .Host
if == "" && .URL != nil {
= .URL.Host
}
if != "" {
fmt.Fprintf(&, "Host: %s\r\n", )
}
}
:= len(.TransferEncoding) > 0 && .TransferEncoding[0] == "chunked"
if len(.TransferEncoding) > 0 {
fmt.Fprintf(&, "Transfer-Encoding: %s\r\n", strings.Join(.TransferEncoding, ","))
}
if .Close {
fmt.Fprintf(&, "Connection: close\r\n")
}
= .Header.WriteSubset(&, reqWriteExcludeHeaderDump)
if != nil {
return nil,
}
io.WriteString(&, "\r\n")
if .Body != nil {
var io.Writer = &
if {
= NewChunkedWriter()
}
_, = io.Copy(, .Body)
if {
.(io.Closer).Close()
io.WriteString(&, "\r\n")
}
}
.Body =
if != nil {
return nil,
}
return .Bytes(), nil
}
type failureToReadBody struct{}
func (failureToReadBody) ([]byte) (int, error) { return 0, errNoBody }
func (failureToReadBody) () error { return nil }
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |