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

Delta Between Two Patch Sets: src/pkg/net/http/httptest/server.go

Issue 6847101: code review 6847101: net/http/httptest: protect against port reuse (Closed)
Left Patch Set: Created 11 years, 4 months ago
Right Patch Set: diff -r cda840e2befc https://go.googlecode.com/hg/ Created 11 years, 4 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:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 // Implementation of Server 5 // Implementation of Server
6 6
7 package httptest 7 package httptest
8 8
9 import ( 9 import (
10 "crypto/tls" 10 "crypto/tls"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ts := NewUnstartedServer(handler) 148 ts := NewUnstartedServer(handler)
149 ts.StartTLS() 149 ts.StartTLS()
150 return ts 150 return ts
151 } 151 }
152 152
153 // Close shuts down the server and blocks until all outstanding 153 // Close shuts down the server and blocks until all outstanding
154 // requests on this server have completed. 154 // requests on this server have completed.
155 func (s *Server) Close() { 155 func (s *Server) Close() {
156 s.Listener.Close() 156 s.Listener.Close()
157 s.wg.Wait() 157 s.wg.Wait()
158 s.CloseClientConnections()
159 if t, ok := http.DefaultTransport.(*http.Transport); ok {
160 t.CloseIdleConnections()
161 }
158 } 162 }
159 163
160 // CloseClientConnections closes any currently open HTTP connections 164 // CloseClientConnections closes any currently open HTTP connections
161 // to the test Server. 165 // to the test Server.
162 func (s *Server) CloseClientConnections() { 166 func (s *Server) CloseClientConnections() {
163 hl, ok := s.Listener.(*historyListener) 167 hl, ok := s.Listener.(*historyListener)
164 if !ok { 168 if !ok {
165 return 169 return
166 } 170 }
167 hl.Lock() 171 hl.Lock()
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 var localhostKey = []byte(`-----BEGIN RSA PRIVATE KEY----- 207 var localhostKey = []byte(`-----BEGIN RSA PRIVATE KEY-----
204 MIIBPQIBAAJBALLgOZgBTI+kO6qAc3LysyKuJM7k+XqUqdgJHEH8gR5uytd1rO7v 208 MIIBPQIBAAJBALLgOZgBTI+kO6qAc3LysyKuJM7k+XqUqdgJHEH8gR5uytd1rO7v
205 tG+VW/YKk3+XAIiCnK7a11apC/ItVEBegM8CAwEAAQJBAI5sxq7naeR9ahyqRkJi 209 tG+VW/YKk3+XAIiCnK7a11apC/ItVEBegM8CAwEAAQJBAI5sxq7naeR9ahyqRkJi
206 SIv2iMxLuPEHaezf5CYOPWjSjBPyVhyRevkhtqEjF/WkgL7C2nWpYHsUcBDBQVF0 210 SIv2iMxLuPEHaezf5CYOPWjSjBPyVhyRevkhtqEjF/WkgL7C2nWpYHsUcBDBQVF0
207 3KECIQDtEGB2ulnkZAahl3WuJziXGLB+p8Wgx7wzSM6bHu1c6QIhAMEp++CaS+SJ 211 3KECIQDtEGB2ulnkZAahl3WuJziXGLB+p8Wgx7wzSM6bHu1c6QIhAMEp++CaS+SJ
208 /TrU0zwY/fW4SvQeb49BPZUF3oqR8Xz3AiEA1rAJHBzBgdOQKdE3ksMUPcnvNJSN 212 /TrU0zwY/fW4SvQeb49BPZUF3oqR8Xz3AiEA1rAJHBzBgdOQKdE3ksMUPcnvNJSN
209 poCcELmz2clVXtkCIQCLytuLV38XHToTipR4yMl6O+6arzAjZ56uq7m7ZRV0TwIh 213 poCcELmz2clVXtkCIQCLytuLV38XHToTipR4yMl6O+6arzAjZ56uq7m7ZRV0TwIh
210 AM65XAOw8Dsg9Kq78aYXiOEDc5DL0sbFUu/SlmRcCg93 214 AM65XAOw8Dsg9Kq78aYXiOEDc5DL0sbFUu/SlmRcCg93
211 -----END RSA PRIVATE KEY----- 215 -----END RSA PRIVATE KEY-----
212 `) 216 `)
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

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