aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/net/http/httptest/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/net/http/httptest/server.go')
-rw-r--r--libgo/go/net/http/httptest/server.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/libgo/go/net/http/httptest/server.go b/libgo/go/net/http/httptest/server.go
index 8ebf681..a9faa9a 100644
--- a/libgo/go/net/http/httptest/server.go
+++ b/libgo/go/net/http/httptest/server.go
@@ -14,7 +14,7 @@ import (
"log"
"net"
"net/http"
- "net/http/internal"
+ "net/http/internal/testcert"
"os"
"strings"
"sync"
@@ -144,7 +144,7 @@ func (s *Server) StartTLS() {
if s.client == nil {
s.client = &http.Client{Transport: &http.Transport{}}
}
- cert, err := tls.X509KeyPair(internal.LocalhostCert, internal.LocalhostKey)
+ cert, err := tls.X509KeyPair(testcert.LocalhostCert, testcert.LocalhostKey)
if err != nil {
panic(fmt.Sprintf("httptest: NewTLSServer: %v", err))
}
@@ -316,6 +316,13 @@ func (s *Server) wrap() {
s.Config.ConnState = func(c net.Conn, cs http.ConnState) {
s.mu.Lock()
defer s.mu.Unlock()
+
+ // Keep Close from returning until the user's ConnState hook
+ // (if any) finishes. Without this, the call to forgetConn
+ // below might send the count to 0 before we run the hook.
+ s.wg.Add(1)
+ defer s.wg.Done()
+
switch cs {
case http.StateNew:
s.wg.Add(1)