mirror of
https://github.com/tinygo-org/net.git
synced 2026-08-14 16:33:39 +00:00
update 'net' package from 1.19.3 to 1.20.5
This commit is contained in:
committed by
deadprogram
parent
d0c97a5292
commit
c3616d9365
+4
-11
@@ -1,4 +1,4 @@
|
||||
// TINYGO: The following is copied and modified from Go 1.19.3 official implementation.
|
||||
// TINYGO: The following is copied and modified from Go 1.20.5 official implementation.
|
||||
|
||||
// TINYGO: Removed trace stuff
|
||||
// TINYGO: Hook readTransfer is onEOF callback to get notified when request of
|
||||
@@ -553,7 +553,7 @@ func readTransfer(msg any, r *bufio.Reader, onEOF func()) (err error) {
|
||||
// or close connection when finished, since multipart is not supported yet
|
||||
switch {
|
||||
case t.Chunked:
|
||||
if noResponseBodyExpected(t.RequestMethod) || !bodyAllowedForStatus(t.StatusCode) {
|
||||
if isResponse && (noResponseBodyExpected(t.RequestMethod) || !bodyAllowedForStatus(t.StatusCode)) {
|
||||
t.Body = NoBody
|
||||
} else {
|
||||
t.Body = &body{src: internal.NewChunkedReader(r), hdr: msg, r: r, closing: t.Close, onHitEOF: onEOF}
|
||||
@@ -596,7 +596,7 @@ func readTransfer(msg any, r *bufio.Reader, onEOF func()) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Checks whether chunked is part of the encodings stack
|
||||
// Checks whether chunked is part of the encodings stack.
|
||||
func chunked(te []string) bool { return len(te) > 0 && te[0] == "chunked" }
|
||||
|
||||
// Checks whether the encoding is explicitly "identity".
|
||||
@@ -687,14 +687,7 @@ func fixLength(isResponse bool, status int, requestMethod string, header Header,
|
||||
}
|
||||
|
||||
// Logic based on response type or status
|
||||
if noResponseBodyExpected(requestMethod) {
|
||||
// For HTTP requests, as part of hardening against request
|
||||
// smuggling (RFC 7230), don't allow a Content-Length header for
|
||||
// methods which don't permit bodies. As an exception, allow
|
||||
// exactly one Content-Length header if its value is "0".
|
||||
if isRequest && len(contentLens) > 0 && !(len(contentLens) == 1 && contentLens[0] == "0") {
|
||||
return 0, fmt.Errorf("http: method cannot contain a Content-Length; got %q", contentLens)
|
||||
}
|
||||
if isResponse && noResponseBodyExpected(requestMethod) {
|
||||
return 0, nil
|
||||
}
|
||||
if status/100 == 1 {
|
||||
|
||||
Reference in New Issue
Block a user