[go] net/http: support mulit same transfer-encoding header

125 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Feb 24, 2021, 3:03:08 AM2/24/21
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded this change for review.

View Change

net/http: support mulit same transfer-encoding header

Hello Golang STD Maintainers,

Here is a proposal about the `net/http/transfer`, we can discuss about this.

In my scenario, the java spring framework will allow application response result with duplicated `transfer-encoding` header, as a result, when the `go service` call the `java app`, the `go service` will raise an error about transfer-encoding.

so, as a result, I want to create a PR to make `go/net/http` could process response with duplicated `chunked` values in `tranfer-encoding` header.

Is that possible ?

Thanks

Change-Id: I21665745ac3a38dfddfc102ea85ba001c2037e7b
GitHub-Last-Rev: 0cd5bf000b7870c45cdc5253a8b56e50547ebb97
GitHub-Pull-Request: golang/go#44565
---
M src/net/http/transfer.go
M src/net/http/transfer_test.go
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/net/http/transfer.go b/src/net/http/transfer.go
index fbb0c39..9d7f4b7 100644
--- a/src/net/http/transfer.go
+++ b/src/net/http/transfer.go
@@ -636,7 +636,14 @@
// surfaces in HTTP/1.1 due to the risk of request smuggling, so we keep it
// strict and simple.
if len(raw) != 1 {
- return &unsupportedTEError{fmt.Sprintf("too many transfer encodings: %q", raw)}
+ // 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])}
diff --git a/src/net/http/transfer_test.go b/src/net/http/transfer_test.go
index f0c28b2..48911c0 100644
--- a/src/net/http/transfer_test.go
+++ b/src/net/http/transfer_test.go
@@ -311,6 +311,10 @@
hdr: Header{"Transfer-Encoding": {"chunked"}},
wantErr: nil,
},
+ {
+ hdr: Header{"Transfer-Encoding": {"chunked", "chunked"}},
+ wantErr: nil,
+ },
}

for i, tt := range tests {

To view, visit change 295829. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I21665745ac3a38dfddfc102ea85ba001c2037e7b
Gerrit-Change-Number: 295829
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-MessageType: newchange

Andy Balholm (Gerrit)

unread,
Apr 20, 2021, 2:14:27 PM4/20/21
to Gerrit Bot, goph...@pubsubhelper.golang.org, Brad Fitzpatrick, Russ Cox, Roberto Clapis, Go Bot, golang-co...@googlegroups.com

Attention is currently required from: Brad Fitzpatrick.

Patch set 1:Code-Review +1

View Change

2 comments:

  • Patchset:

    • Patch Set #1:

      Let's see if getting a review on this gets it moving again…

  • File src/net/http/transfer.go:

    • Patch Set #1, Line 640: uniqRaw := map[string]interface{}{}

      It is more idiomatic to represent a set as map[string]struct{} or map[string]bool.

      But I wonder if it would be simpler to iterate over raw, and return an unsupportedTEError if any of the values isn't "chunked".

To view, visit change 295829. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I21665745ac3a38dfddfc102ea85ba001c2037e7b
Gerrit-Change-Number: 295829
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Andy Balholm <an...@balholm.com>
Gerrit-Reviewer: Brad Fitzpatrick <brad...@golang.org>
Gerrit-CC: Go Bot <go...@golang.org>
Gerrit-CC: Roberto Clapis <rob...@golang.org>
Gerrit-CC: Russ Cox <r...@golang.org>
Gerrit-Attention: Brad Fitzpatrick <brad...@golang.org>
Gerrit-Comment-Date: Tue, 20 Apr 2021 18:14:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Gopher Robot (Gerrit)

unread,
Feb 13, 2025, 5:00:48 PMFeb 13
to Gerrit Bot, goph...@pubsubhelper.golang.org, Andy Balholm, Brad Fitzpatrick, Russ Cox, golang-co...@googlegroups.com

Gopher Robot abandoned this change

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: abandon
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I21665745ac3a38dfddfc102ea85ba001c2037e7b
Gerrit-Change-Number: 295829
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Andy Balholm <an...@balholm.com>
Gerrit-Reviewer: Brad Fitzpatrick <brad...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages