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

Side by Side Diff: src/pkg/net/http/httputil/dump.go

Issue 6483061: code review 6483061: net/http/httputil: fix race in DumpRequestOut (Closed)
Patch Set: diff -r 288d68924d65 https://go.googlecode.com/hg/ Created 12 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "fmt" 10 "fmt"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 pr, pw := io.Pipe() 82 pr, pw := io.Pipe()
83 dr := &delegateReader{c: make(chan io.Reader)} 83 dr := &delegateReader{c: make(chan io.Reader)}
84 // Wait for the request before replying with a dummy response: 84 // Wait for the request before replying with a dummy response:
85 go func() { 85 go func() {
86 http.ReadRequest(bufio.NewReader(pr)) 86 http.ReadRequest(bufio.NewReader(pr))
87 dr.c <- strings.NewReader("HTTP/1.1 204 No Content\r\n\r\n") 87 dr.c <- strings.NewReader("HTTP/1.1 204 No Content\r\n\r\n")
88 }() 88 }()
89 89
90 t := &http.Transport{ 90 t := &http.Transport{
91 Dial: func(net, addr string) (net.Conn, error) { 91 Dial: func(net, addr string) (net.Conn, error) {
92 » » » return &dumpConn{io.MultiWriter(pw, &buf), dr}, nil 92 » » » return &dumpConn{io.MultiWriter(&buf, pw), dr}, nil
93 }, 93 },
94 } 94 }
95 95
96 _, err := t.RoundTrip(reqSend) 96 _, err := t.RoundTrip(reqSend)
97 97
98 req.Body = save 98 req.Body = save
99 if err != nil { 99 if err != nil {
100 return nil, err 100 return nil, err
101 } 101 }
102 return buf.Bytes(), nil 102 return buf.Bytes(), nil
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 err = resp.Write(&b) 221 err = resp.Write(&b)
222 resp.Body = save 222 resp.Body = save
223 resp.ContentLength = savecl 223 resp.ContentLength = savecl
224 if err != nil { 224 if err != nil {
225 return 225 return
226 } 226 }
227 dump = b.Bytes() 227 dump = b.Bytes()
228 return 228 return
229 } 229 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

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