mirror of
https://github.com/golang/go
synced 2024-11-22 03:54:39 -07:00
net/http: support mulit same transfer-encoding header
This commit is contained in:
parent
6ba4a300d8
commit
0cd5bf000b
@ -636,8 +636,15 @@ func (t *transferReader) parseTransferEncoding() error {
|
||||
// surfaces in HTTP/1.1 due to the risk of request smuggling, so we keep it
|
||||
// strict and simple.
|
||||
if len(raw) != 1 {
|
||||
// support Transfer-Encoding: [chunked, chunked, chunked] for microservice remote call
|
||||
uniqRaw := map[string]interface{}{}
|
||||
for _, part := range raw {
|
||||
uniqRaw[strings.ToLower(textproto.TrimString(part))] = nil
|
||||
}
|
||||
if len(uniqRaw) > 1 {
|
||||
return &unsupportedTEError{fmt.Sprintf("too many transfer encodings: %q", raw)}
|
||||
}
|
||||
}
|
||||
if strings.ToLower(textproto.TrimString(raw[0])) != "chunked" {
|
||||
return &unsupportedTEError{fmt.Sprintf("unsupported transfer encoding: %q", raw[0])}
|
||||
}
|
||||
|
@ -311,6 +311,10 @@ func TestParseTransferEncoding(t *testing.T) {
|
||||
hdr: Header{"Transfer-Encoding": {"chunked"}},
|
||||
wantErr: nil,
|
||||
},
|
||||
{
|
||||
hdr: Header{"Transfer-Encoding": {"chunked", "chunked"}},
|
||||
wantErr: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user