diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2018-10-25 02:02:57 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-10-25 03:03:15 +0000 |
| commit | fc4f2e5692ab800a450e07c3d983eda02dfd4711 (patch) | |
| tree | 67a90e096fb462a66d85bd1974d9f8461d3ff90a /src/net/http/server.go | |
| parent | c942191c203c096637e1e8d27dfccc4968ce5436 (diff) | |
| download | go-fc4f2e5692ab800a450e07c3d983eda02dfd4711.tar.xz | |
net/http: fix comment change omitted between versions of CL 143177
Updates #23689
Change-Id: Icddec2fcc39802cacd651a9c94290e86cf1e48d1
Reviewed-on: https://go-review.googlesource.com/c/144517
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/net/http/server.go')
| -rw-r--r-- | src/net/http/server.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/net/http/server.go b/src/net/http/server.go index 82abdd388e..6e1ccff4cd 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -1782,11 +1782,9 @@ func (c *conn) serve(ctx context.Context) { c.rwc.SetWriteDeadline(time.Now().Add(d)) } if err := tlsConn.Handshake(); err != nil { - // If the handshake failed, one reason might be a - // misconfigured client sending an HTTP request. If so, reach - // into the *tls.Conn unexported fields in a gross way so we - // can reply on the plaintext connection. At least there's a - // test that'll break if we rearrange the *tls.Conn struct. + // If the handshake failed due to the client not speaking + // TLS, assume they're speaking plaintext HTTP and write a + // 400 response on the TLS conn's underlying net.Conn. if re, ok := err.(tls.RecordHeaderError); ok && re.Conn != nil && tlsRecordHeaderLooksLikeHTTP(re.RecordHeader) { io.WriteString(re.Conn, "HTTP/1.0 400 Bad Request\r\n\r\nClient sent an HTTP request to an HTTPS server.\n") re.Conn.Close() |
