// parseTransferEncoding sets t.Chunked based on the Transfer-Encoding header.
parseTransferEncoding sets t.Chunked based on the Transfer-Encoding header.
// parseTransferEncoding sets t . Chunked based on the Transfer - Encoding header .
func (t *transferReader) parseTransferEncoding() error {
	raw, present := t.Header["Transfer-Encoding"]
	if !present {
		return nil
	}
	delete(t.Header, "Transfer-Encoding")
	if !t.protoAtLeast(1, 1) {
		return nil
	}
	for _, v := range raw {
		if strings.ToLower(textproto.TrimString(v)) != "chunked" {
			return &unsupportedTEError{fmt.Sprintf("unsupported transfer encoding: %q", v)}
		}
	}
	 but also: "If a message is received with both a Transfer-Encoding and a
	 Content-Length header field, the Transfer-Encoding overrides the
	 Content-Length. Such a message might indicate an attempt to perform
	 request smuggling (Section 9.5) or response splitting (Section 9.4) and
	 ought to be handled as an error. A sender MUST remove the received
	 Content-Length field prior to forwarding such a message downstream."
	 Reportedly, these appear in the wild.
	delete(t.Header, "Content-Length")
	t.Chunked = true
	return nil
}
func ( t * transferReader ) parseTransferEncoding ( ) error { raw , present := t . Header [ " " ] if ! present { return nil } delete ( t . Header , " " ) if ! t . protoAtLeast ( 1 , 1 ) { return nil } for _ , v := range raw { if strings . ToLower ( textproto . TrimString ( v ) ) != " " { return & unsupportedTEError { fmt . Sprintf ( " " , v ) } } } delete ( t . Header , " " ) t . Chunked = true return nil }
parseTransferEncoding sets t.Chunked based on the Transfer-Encoding header.
parseTransferEncoding sets t . Chunked based on the Transfer - Encoding header .
// Issue 12785; ignore Transfer-Encoding on HTTP/1.0 requests. // The only transfer encoding we support is "chunked". If it is specified // multiple times, it is treated the same as if it were specified only once. // RFC 7230 3.3.2 says "A sender MUST NOT send a Content-Length header field // in any message that contains a Transfer-Encoding header field." // // but also: "If a message is received with both a Transfer-Encoding and a // Content-Length header field, the Transfer-Encoding overrides the // Content-Length. Such a message might indicate an attempt to perform // request smuggling (Section 9.5) or response splitting (Section 9.4) and // ought to be handled as an error. A sender MUST remove the received // Content-Length field prior to forwarding such a message downstream." // // Reportedly, these appear in the wild.