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

Side by Side Diff: src/pkg/net/http/transport.go

Issue 6869053: code review 6869053: net/http: populate ContentLength in HEAD responses (Closed)
Patch Set: diff -r b7fd6fe38b63 https://go.googlecode.com/hg/ Created 11 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // HTTP client implementation. See RFC 2616. 5 // HTTP client implementation. See RFC 2616.
6 // 6 //
7 // This is the low-level Transport implementation of RoundTripper. 7 // This is the low-level Transport implementation of RoundTripper.
8 // The high-level interface is in client.go. 8 // The high-level interface is in client.go.
9 9
10 package http 10 package http
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 resp.Body = &readFirstCloseBoth{&discard OnCloseReadCloser{gzReader}, resp.Body} 597 resp.Body = &readFirstCloseBoth{&discard OnCloseReadCloser{gzReader}, resp.Body}
598 } 598 }
599 } 599 }
600 resp.Body = &bodyEOFSignal{body: resp.Body} 600 resp.Body = &bodyEOFSignal{body: resp.Body}
601 } 601 }
602 602
603 if err != nil || resp.Close || rc.req.Close { 603 if err != nil || resp.Close || rc.req.Close {
604 alive = false 604 alive = false
605 } 605 }
606 606
607 » » // TODO(bradfitz): this hasBody conflicts with the defition 607 » » hasBody := resp != nil && (rc.req.Method != "HEAD" && resp.Conte ntLength != 0)
rsc 2012/12/06 04:54:08 () are weird; did you mean || inside instead of &&
608 » » // above which excludes HEAD requests. Is this one
609 » » // incomplete?
610 » » hasBody := resp != nil && resp.ContentLength != 0
611 var waitForBodyRead chan bool 608 var waitForBodyRead chan bool
612 if hasBody { 609 if hasBody {
613 lastbody = resp.Body 610 lastbody = resp.Body
614 waitForBodyRead = make(chan bool, 1) 611 waitForBodyRead = make(chan bool, 1)
615 resp.Body.(*bodyEOFSignal).fn = func(err error) { 612 resp.Body.(*bodyEOFSignal).fn = func(err error) {
616 alive1 := alive 613 alive1 := alive
617 if err != nil { 614 if err != nil {
618 alive1 = false 615 alive1 = false
619 } 616 }
620 if alive1 && !pc.t.putIdleConn(pc) { 617 if alive1 && !pc.t.putIdleConn(pc) {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 885
889 // discardOnCloseReadCloser consumes all its input on Close. 886 // discardOnCloseReadCloser consumes all its input on Close.
890 type discardOnCloseReadCloser struct { 887 type discardOnCloseReadCloser struct {
891 io.ReadCloser 888 io.ReadCloser
892 } 889 }
893 890
894 func (d *discardOnCloseReadCloser) Close() error { 891 func (d *discardOnCloseReadCloser) Close() error {
895 io.Copy(ioutil.Discard, d.ReadCloser) // ignore errors; likely invalid o r already closed 892 io.Copy(ioutil.Discard, d.ReadCloser) // ignore errors; likely invalid o r already closed
896 return d.ReadCloser.Close() 893 return d.ReadCloser.Close()
897 } 894 }
OLDNEW

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