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

Issue 4603041: code review 4603041: http: fix serialization of 0-lengthed requests (Closed)

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

Description

http: fix handling of 0-lengthed http requests Via Russ Ross' bug report on golang-nuts, it was not possible to send an HTTP request with a zero length body with either a Content-Length (it was stripped) or chunking (it wasn't set). This means Go couldn't upload 0-length objects to Amazon S3. (which aren't as silly as they might sound, as S3 objects can have key/values associated with them, set in the headers) Amazon further doesn't supported chunked uploads. (not Go's problem, but we should be able to let users set an explicit Content-Length, even if it's zero.) To fix the ambiguity of an explicit zero Content-Length and the Request struct's default zero value, users need to explicit set TransferEncoding to []string{"identity"} to force the Request.Write to include a Content-Length: 0. identity is in RFC 2616 but is ignored pretty much everywhere. We don't even then serialize it on the wire, since it's kinda useless, except as an internal sentinel value. The "identity" value is then documented, but most users can ignore that because NewRequest now sets that. And adds more tests.

Patch Set 1 #

Patch Set 2 : diff -r 1a47bb34b2ba https://go.googlecode.com/hg #

Patch Set 3 : diff -r 1a47bb34b2ba https://go.googlecode.com/hg #

Patch Set 4 : diff -r 1a47bb34b2ba https://go.googlecode.com/hg #

Unified diffs Side-by-side diffs Delta from patch set Stats (+49 lines, -6 lines) Patch
M src/pkg/http/request.go View 1 2 chunks +8 lines, -3 lines 0 comments Download
M src/pkg/http/requestwrite_test.go View 1 1 chunk +34 lines, -2 lines 0 comments Download
M src/pkg/http/transfer.go View 1 3 chunks +7 lines, -1 line 0 comments Download

Messages

Total messages: 5
bradfitz
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg
13 years, 11 months ago (2011-06-08 22:15:13 UTC) #1
rsc
LGTM
13 years, 11 months ago (2011-06-08 22:46:56 UTC) #2
bradfitz
*** Submitted as http://code.google.com/p/go/source/detail?r=58a6bdac3d12 *** http: fix handling of 0-lengthed http requests Via Russ Ross' ...
13 years, 11 months ago (2011-06-08 22:59:30 UTC) #3
rsc
btw, it occurred to me a little later that this could just work if with ...
13 years, 11 months ago (2011-06-09 00:53:13 UTC) #4
bradfitz
13 years, 11 months ago (2011-06-09 00:57:39 UTC) #5
Cute!  I like it.

I can update the code.

On Wed, Jun 8, 2011 at 5:53 PM, Russ Cox <rsc@golang.org> wrote:

> btw, it occurred to me a little later that this could just work
> if with Content-Length 0 the code tried to read 1 byte before
> deciding to use chunked.  it's not super clean but it's no more
> ugly than having to remember to say {"identity"}, and less work
> for users.
>
Sign in to reply to this message.

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