Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1155)

Issue 7182045: code review 7182045: net/http: fix Content-Length/Transfer-Encoding on HEAD ...

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 2 months ago by jgc
Modified:
11 years, 8 months ago
Reviewers:
bradfitz
CC:
golang-dev, bradfitz
Visibility:
Public.

Description

net/http: fix Content-Length/Transfer-Encoding on HEAD requests net/http currently assumes that the response to a HEAD request will always have a Content-Length header. This is incorrect. RFC2616 says: "The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification." This means that three cases are possible: a Content-Length header, a Transfer-Encoding header or neither. In the wild the following sites exhibit these behaviours (curl -I): HEAD on http://www.google.co.uk/ has Transfer-Encoding: chunked HEAD on http://www.bbc.co.uk/ has Content-Length: 45247 HEAD on http://edition.cnn.com/ has neither header This patch does not remove the ErrMissingContentLength error for compatibility reasons, but it is no longer used.

Patch Set 1 #

Patch Set 2 : diff -r b68f084eaba7 https://code.google.com/p/go #

Total comments: 4

Patch Set 3 : diff -r b68f084eaba7 https://code.google.com/p/go #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+87 lines, -33 lines) Patch
M src/pkg/net/http/response_test.go View 1 2 5 chunks +85 lines, -20 lines 0 comments Download
M src/pkg/net/http/transfer.go View 1 3 chunks +2 lines, -13 lines 2 comments Download

Messages

Total messages: 9
jgc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go
12 years, 2 months ago (2013-01-22 16:13:43 UTC) #1
bradfitz
https://codereview.appspot.com/7182045/diff/2001/src/pkg/net/http/response_test.go File src/pkg/net/http/response_test.go (right): https://codereview.appspot.com/7182045/diff/2001/src/pkg/net/http/response_test.go#newcode182 src/pkg/net/http/response_test.go:182: "HTTP/1.0 200 OK\r\n" + Little weird to see "HTTP/1.0" ...
12 years, 2 months ago (2013-01-22 20:43:14 UTC) #2
jgc
https://codereview.appspot.com/7182045/diff/2001/src/pkg/net/http/response_test.go File src/pkg/net/http/response_test.go (right): https://codereview.appspot.com/7182045/diff/2001/src/pkg/net/http/response_test.go#newcode182 src/pkg/net/http/response_test.go:182: "HTTP/1.0 200 OK\r\n" + Agreed; will change to HTTP/1.1. ...
12 years, 2 months ago (2013-01-23 09:25:35 UTC) #3
jgc
Hello golang-dev@googlegroups.com, bradfitz@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 2 months ago (2013-01-23 09:35:03 UTC) #4
bradfitz
https://codereview.appspot.com/7182045/diff/8001/src/pkg/net/http/transfer.go File src/pkg/net/http/transfer.go (left): https://codereview.appspot.com/7182045/diff/8001/src/pkg/net/http/transfer.go#oldcode125 src/pkg/net/http/transfer.go:125: if t.ResponseToHEAD { this CL doesn't contain a test ...
12 years, 2 months ago (2013-01-24 01:01:06 UTC) #5
jgc
https://codereview.appspot.com/7182045/diff/8001/src/pkg/net/http/transfer.go File src/pkg/net/http/transfer.go (left): https://codereview.appspot.com/7182045/diff/8001/src/pkg/net/http/transfer.go#oldcode125 src/pkg/net/http/transfer.go:125: if t.ResponseToHEAD { On 2013/01/24 01:01:06, bradfitz wrote: > ...
12 years, 2 months ago (2013-01-25 17:00:50 UTC) #6
bradfitz
LGTM On Fri, Jan 25, 2013 at 9:00 AM, <jgrahamc@gmail.com> wrote: > > https://codereview.appspot.**com/7182045/diff/8001/src/pkg/** > ...
12 years, 2 months ago (2013-01-25 18:20:04 UTC) #7
bradfitz
*** Submitted as https://code.google.com/p/go/source/detail?r=8184de6499b0 *** net/http: fix Content-Length/Transfer-Encoding on HEAD requests net/http currently assumes that ...
12 years, 2 months ago (2013-01-25 18:20:23 UTC) #8
remyoudompheng
11 years, 8 months ago (2013-07-20 20:01:31 UTC) #9
R=close
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b