I started doing this a few weeks ago but got sidetracked. Thanks for looking at ...
14 years, 1 month ago
(2011-02-16 04:27:47 UTC)
#3
I started doing this a few weeks ago but got sidetracked.
Thanks for looking at it. I'll review the CL tomorrow.
Pet peeve without looking at the code, just reacting to the
discussion: "Get" is a Java word. It is necessary in
Java because you can't have a field named foo and
a method named foo in the same class. It is not
necessary in Go: because of the export rules the field
is typically named foo and the method Foo.
Any time you think you need a GetFoo method, just
call it Foo instead. It's shorter, clearer, and easier.
Russ
This is a fair suggestion. Maybe for this or the next CL. Let's see what ...
14 years, 1 month ago
(2011-02-16 07:07:18 UTC)
#4
This is a fair suggestion. Maybe for this or the next CL. Let's see what Russ
thinks.
—Petar
On Tuesday, February 15, 2011 at 9:56 PM, gary b wrote:
> I recommend adding a type similar to Twister's HeaderMap
(http://garyburd.github.com/twister/pkg/web.html#HeaderMap) and declaring
headers as type HeaderMap instead of map[string][]string. Twister's HeaderMap
has methods for working with multi-value headers. Here are some examples where
HeaderMap will improve the code in this changeset:
>
> Several instances of this pattern in request.go:
>
> ct_, ok := r.Header["Content-Type"]
> var ct string
> if ok {
> ct = ct_[0]
> }
>
> can be replaced with:
>
> ct, ok := r.Header.Get("Content-Type")
>
> The functionality in the new functions:
>
> func (r *Response) GetHeaderFirst(key string) string
> GetFirstValue(header map[string][]string, key string) string
>
> is available in a HeaderMap method:
>
> func (m HeaderMap) GetDef(key string, def string) string
>
> HeaderMap is a better place for this functionality because the functionality
is useful outside the context of HTTP responses.
>
>
>
>
Thanks for cleaning this up. I agree with the suggestion about having a Header type, ...
14 years, 1 month ago
(2011-02-16 23:04:43 UTC)
#5
Thanks for cleaning this up.
I agree with the suggestion about having a Header type, like:
---
// A Header represents a MIME-style header mapping
// keys to sets of values.
type Header map[string][]string
// Add adds the key, value pair to the header.
// It appends to any existing values associated with key.
func (h Header) Add(key, value string)
// Set sets the header entries associated with key to
// the single element value. It replaces any existing
// values associated with key.
func (h Header) Set(key, value string)
// Get gets the first value associated with the given key.
// If there are no values associated with the key, Get returns "".
// Get is a convenience method. For more complex queries,
// access the map directly.
func (h Header) Get(key string) string
// Del deletes the values associated with key.
func (h Header) Del(key string)
---
It probably belongs in textproto but I would be happy to hear
counterarguments.
This will mean that the Trailer field has type Header but so be it.
When you write a header literal you don't need to echo the []string
in the nested composite literal anymore:
h := Header{
"Cookie": {"xxx", "yyy"},
}
Please avoid the _ suffix on variable names.
I've already implemented the cookie mechanism, factoring your concerns. It is coming in the CL ...
14 years, 1 month ago
(2011-02-17 00:41:30 UTC)
#6
I've already implemented the cookie mechanism, factoring your concerns.
It is coming in the CL right after this one.
--P
—Petar
On Wednesday, February 16, 2011 at 7:18 PM, mattn wrote:
>
> > When you write a header literal you don't need to echo the []string
> > in the nested composite literal anymore:
> > h := Header{
> > "Cookie": {"xxx", "yyy"},
> > }
>
> Sounds good, And I hope Cookie include expire/domain/path/secure/HttpOnly like
below.
>
> https://github.com/mattn/go-session-manager/blob/master/session.go#L13
>
> Currently, go's header is joined with comma for cookie.
> Then we should parse Set-Cookie like below.
>
> https://github.com/mattn/go-session-manager/blob/master/session.go#L155
>
> If possible, I want that it parse Cookies in http package.
>
> Thanks.
> - Yasuhiro Matsumoto
>
>
Also, I think that textproto.CanonicalHeaderKey should be renamed to textproto.CanonicalMIMEKey On 2011/02/17 16:57:16, petar-m wrote: ...
14 years, 1 month ago
(2011-02-17 17:11:50 UTC)
#9
Also, I think that
textproto.CanonicalHeaderKey should be renamed to
textproto.CanonicalMIMEKey
On 2011/02/17 16:57:16, petar-m wrote:
> Hello rsc, mattn (cc: mailto:golang-dev@googlegroups.com),
>
> Please take another look.
http://codereview.appspot.com/4185053/diff/13001/src/pkg/http/client.go File src/pkg/http/client.go (left): http://codereview.appspot.com/4185053/diff/13001/src/pkg/http/client.go#oldcode93 src/pkg/http/client.go:93: var proxyURL *URL It seems that proxy support was ...
14 years, 1 month ago
(2011-02-18 01:39:44 UTC)
#14
> rsc, Shall we fix 4177042 in this time? > Of course, I should check ...
14 years, 1 month ago
(2011-02-18 13:52:59 UTC)
#19
> rsc, Shall we fix 4177042 in this time?
> Of course, I should check another pass about manipurating URL and local
> path.
The code in this CL is fine.
I will take care of the path problems next week.
Russ
This looks great. I like how this turned out. http://codereview.appspot.com/4185053/diff/16001/src/pkg/http/client.go File src/pkg/http/client.go (right): http://codereview.appspot.com/4185053/diff/16001/src/pkg/http/client.go#newcode136 src/pkg/http/client.go:136: ...
14 years, 1 month ago
(2011-02-22 21:53:44 UTC)
#20
Please change CL description to http: introduce Header type, implement with net/textproto textproto: introduce Header ...
14 years, 1 month ago
(2011-02-22 23:26:29 UTC)
#24
Please change CL description to
http: introduce Header type, implement with net/textproto
textproto: introduce Header type
websocket: use new interface to access Header
I would have done this during submit but I am unable
to submit this.
It appears that some changes to
net/textproto/reader_test are missing?
Russ
—Petar On Tuesday, February 22, 2011 at 6:26 PM, Russ Cox wrote: > Please change ...
14 years, 1 month ago
(2011-02-22 23:47:19 UTC)
#26
—Petar
On Tuesday, February 22, 2011 at 6:26 PM, Russ Cox wrote:
> Please change CL description to
>
> http: introduce Header type, implement with net/textproto
> textproto: introduce Header type
> websocket: use new interface to access Header
>
> I would have done this during submit but I am unable
> to submit this.
>
> It appears that some changes to
> net/textproto/reader_test are missing?
>
I'm not sure what you mean?
Russ
>
I think reader_test.go is missing from the CL. Russ On Feb 22, 2011 6:47 PM, ...
14 years, 1 month ago
(2011-02-22 23:53:56 UTC)
#29
I think reader_test.go is missing from the CL.
Russ
On Feb 22, 2011 6:47 PM, "Petar Maymounkov" <petarm@gmail.com> wrote:
>
>
> —Petar
> On Tuesday, February 22, 2011 at 6:26 PM, Russ Cox wrote:
>> Please change CL description to
>>
>> http: introduce Header type, implement with net/textproto
>> textproto: introduce Header type
>> websocket: use new interface to access Header
>>
>> I would have done this during submit but I am unable
>> to submit this.
>>
>> It appears that some changes to
>> net/textproto/reader_test are missing?
>>
> I'm not sure what you mean?
>
> Russ
>>
I'm sorry to keep bouncing this back to you, but I ran all.bash and it ...
14 years, 1 month ago
(2011-02-23 04:04:49 UTC)
#30
I'm sorry to keep bouncing this back to you, but I ran
all.bash and it doesn't pass with this CL patched in.
make[2]: Leaving directory `/home/rsc/g/go/src/pkg/http'
--- FAIL: http.TestRequestWrite (0.0 seconds)
Test 0, expecting:
GET http://www.techcrunch.com/ HTTP/1.1
Host: www.techcrunch.com
User-Agent: Fake
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding: gzip,deflate
Accept-Language: en-us,en;q=0.5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Keep-Alive: 300
Proxy-Connection: keep-alive
Got:
GET http://www.techcrunch.com/ HTTP/1.1
Host: www.techcrunch.com
User-Agent: Fake
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding: gzip,deflate
Accept-Language: en-us,en;q=0.5
Keep-Alive: 300
Proxy-Connection: keep-alive
FAIL
Could you try running all.bash on your machine?
Thanks.
Russ
Issue 4185053: code review 4185053: http: introduce Header type, implement with net/textproto
(Closed)
Created 14 years, 1 month ago by petar-m
Modified 14 years, 1 month ago
Reviewers:
Base URL:
Comments: 113