File tree 4 files changed +3
-42
lines changed
4 files changed +3
-42
lines changed Original file line number Diff line number Diff line change @@ -677,10 +677,7 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
677
677
methods will return errors after a shutdown or close.
678
678
</ p >
679
679
680
- < p > <!-- CL 89275 -->
681
- The HTTP server will no longer automatically set the Content-Type if a
682
- < code > Handler</ code > sets the "< code > X-Content-Type-Options</ code > " header to "< code > nosniff</ code > ".
683
- </ p >
680
+ <!-- CL 89275 was reverted before Go 1.11 -->
684
681
685
682
< p > <!-- CL 93296 -->
686
683
The constant < code > StatusMisdirectedRequest</ code > is now defined for HTTP status code 421.
Original file line number Diff line number Diff line change @@ -3585,26 +3585,6 @@ func TestHeaderToWire(t *testing.T) {
3585
3585
return nil
3586
3586
},
3587
3587
},
3588
- {
3589
- name : "Nosniff without Content-type" ,
3590
- handler : func (rw ResponseWriter , r * Request ) {
3591
- rw .Header ().Set ("X-Content-Type-Options" , "nosniff" )
3592
- rw .WriteHeader (200 )
3593
- rw .Write ([]byte ("<!doctype html>\n <html><head></head><body>some html</body></html>" ))
3594
- },
3595
- check : func (got , logs string ) error {
3596
- if ! strings .Contains (got , "Content-Type: application/octet-stream\r \n " ) {
3597
- return errors .New ("Output should have an innocuous content-type" )
3598
- }
3599
- if strings .Contains (got , "text/html" ) {
3600
- return errors .New ("Output should not have a guess" )
3601
- }
3602
- if ! strings .Contains (logs , "X-Content-Type-Options:nosniff but no Content-Type" ) {
3603
- return errors .New ("Expected log message" )
3604
- }
3605
- return nil
3606
- },
3607
- },
3608
3588
}
3609
3589
for _ , tc := range tests {
3610
3590
ht := newHandlerTest (HandlerFunc (tc .handler ))
Original file line number Diff line number Diff line change @@ -1360,15 +1360,7 @@ func (cw *chunkWriter) writeHeader(p []byte) {
1360
1360
// If no content type, apply sniffing algorithm to body.
1361
1361
_ , haveType := header ["Content-Type" ]
1362
1362
if ! haveType && ! hasTE && len (p ) > 0 {
1363
- if cto := header .get ("X-Content-Type-Options" ); strings .EqualFold ("nosniff" , cto ) {
1364
- // nosniff is an explicit directive not to guess a content-type.
1365
- // Content-sniffing is no less susceptible to polyglot attacks via
1366
- // hosted content when done on the server.
1367
- setHeader .contentType = "application/octet-stream"
1368
- w .conn .server .logf ("http: WriteHeader called with X-Content-Type-Options:nosniff but no Content-Type" )
1369
- } else {
1370
- setHeader .contentType = DetectContentType (p )
1371
- }
1363
+ setHeader .contentType = DetectContentType (p )
1372
1364
}
1373
1365
} else {
1374
1366
for _ , k := range suppressedHeaders (code ) {
You can’t perform that action at this time.
0 commit comments