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

Delta Between Two Patch Sets: src/net/http/httputil/dump.go

Issue 144650044: code review 144650044: net/http/httputil: ensure DumpRequestOut dumps all of Body (Closed)
Left Patch Set: diff -r 2e467bc60e64def06419194f48fe0d6c8b56765d https://go.googlecode.com/hg/ Created 10 years, 5 months ago
Right Patch Set: diff -r b0e30135710173e2af2140fc019d408bcd1b45ab https://go.googlecode.com/hg/ Created 10 years, 5 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/net/http/httputil/dump_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 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 package httputil 5 package httputil
6 6
7 import ( 7 import (
8 "bufio" 8 "bufio"
9 "bytes" 9 "bytes"
10 "errors" 10 "errors"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // with a dummy response. 95 // with a dummy response.
96 var buf bytes.Buffer // records the output 96 var buf bytes.Buffer // records the output
97 pr, pw := io.Pipe() 97 pr, pw := io.Pipe()
98 defer pr.Close() 98 defer pr.Close()
99 defer pw.Close() 99 defer pw.Close()
100 dr := &delegateReader{c: make(chan io.Reader)} 100 dr := &delegateReader{c: make(chan io.Reader)}
101 // Wait for the request before replying with a dummy response: 101 // Wait for the request before replying with a dummy response:
102 go func() { 102 go func() {
103 req, err := http.ReadRequest(bufio.NewReader(pr)) 103 req, err := http.ReadRequest(bufio.NewReader(pr))
104 if err == nil { 104 if err == nil {
105 » » » // Ensure all the body is read otherwise we'll get 105 » » » // Ensure all the body is read; otherwise
r 2014/09/30 18:20:56 s/read/read;/
106 » » » // a partial dump. 106 » » » // we'll get a partial dump.
107 io.Copy(ioutil.Discard, req.Body) 107 io.Copy(ioutil.Discard, req.Body)
108 req.Body.Close() 108 req.Body.Close()
109 } 109 }
110 dr.c <- strings.NewReader("HTTP/1.1 204 No Content\r\n\r\n") 110 dr.c <- strings.NewReader("HTTP/1.1 204 No Content\r\n\r\n")
111 }() 111 }()
112 112
113 t := &http.Transport{ 113 t := &http.Transport{
114 DisableKeepAlives: true, 114 DisableKeepAlives: true,
115 Dial: func(net, addr string) (net.Conn, error) { 115 Dial: func(net, addr string) (net.Conn, error) {
116 return &dumpConn{io.MultiWriter(&buf, pw), dr}, nil 116 return &dumpConn{io.MultiWriter(&buf, pw), dr}, nil
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 if err == errNoBody { 275 if err == errNoBody {
276 err = nil 276 err = nil
277 } 277 }
278 resp.Body = save 278 resp.Body = save
279 resp.ContentLength = savecl 279 resp.ContentLength = savecl
280 if err != nil { 280 if err != nil {
281 return nil, err 281 return nil, err
282 } 282 }
283 return b.Bytes(), nil 283 return b.Bytes(), nil
284 } 284 }
LEFTRIGHT

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