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

Unified Diff: testutil/http.go

Issue 9545045: Support EC2_ env variables (Closed)
Patch Set: Support EC2_ env variables Created 11 years, 10 months ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « s3/s3_test.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testutil/http.go
=== modified file 'testutil/http.go'
--- testutil/http.go 2013-02-01 05:55:19 +0000
+++ testutil/http.go 2013-05-23 03:13:02 +0000
@@ -15,6 +15,7 @@
URL string
Timeout time.Duration
started bool
+ listener net.Listener
request chan *http.Request
response chan ResponseFunc
}
@@ -42,11 +43,11 @@
if err != nil {
panic(err)
}
- l, err := net.Listen("tcp", u.Host)
+ s.listener, err = net.Listen("tcp", u.Host)
if err != nil {
panic(err)
}
- go http.Serve(l, s)
+ go http.Serve(s.listener, s)
s.Response(203, nil, "")
for {
@@ -60,6 +61,17 @@
s.WaitRequest() // Consume dummy request.
}
+func (s *HTTPServer) Stop() {
+ if s.listener == nil {
+ return
+ }
+ err := s.listener.Close()
+ if err != nil {
+ panic(err)
+ }
+ s.listener = nil
+}
+
// Flush discards all pending requests and responses.
func (s *HTTPServer) Flush() {
for {
« no previous file with comments | « s3/s3_test.go ('k') | no next file » | no next file with comments »

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