File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -2677,6 +2677,14 @@ func (rws *responseWriterState) writeHeader(code int) {
2677
2677
// Per RFC 8297 we must not clear the current header map
2678
2678
h := rws .handlerHeader
2679
2679
2680
+ _ , cl := h ["Content-Length" ]
2681
+ _ , te := h ["Transfer-Encoding" ]
2682
+ if cl || te {
2683
+ h = h .Clone ()
2684
+ h .Del ("Content-Length" )
2685
+ h .Del ("Transfer-Encoding" )
2686
+ }
2687
+
2680
2688
if rws .conn .writeHeaders (rws .stream , & writeResHeaders {
2681
2689
streamID : rws .stream .id ,
2682
2690
httpResCode : code ,
Original file line number Diff line number Diff line change @@ -4392,6 +4392,7 @@ func TestServerSendsProcessing(t *testing.T) {
4392
4392
func TestServerSendsEarlyHints (t * testing.T ) {
4393
4393
testServerResponse (t , func (w http.ResponseWriter , r * http.Request ) error {
4394
4394
h := w .Header ()
4395
+ h .Add ("Content-Length" , "123" )
4395
4396
h .Add ("Link" , "</style.css>; rel=preload; as=style" )
4396
4397
h .Add ("Link" , "</script.js>; rel=preload; as=script" )
4397
4398
w .WriteHeader (http .StatusEarlyHints )
@@ -4437,7 +4438,7 @@ func TestServerSendsEarlyHints(t *testing.T) {
4437
4438
{"link" , "</script.js>; rel=preload; as=script" },
4438
4439
{"link" , "</foo.js>; rel=preload; as=script" },
4439
4440
{"content-type" , "text/plain; charset=utf-8" },
4440
- {"content-length" , "5 " },
4441
+ {"content-length" , "123 " },
4441
4442
}
4442
4443
4443
4444
if ! reflect .DeepEqual (goth , wanth ) {
You can’t perform that action at this time.
0 commit comments