diff --git a/client_test.go b/client_test.go index c9bc588..cd5748c 100644 --- a/client_test.go +++ b/client_test.go @@ -1008,9 +1008,6 @@ func testClientGet(t *testing.T, c clientGetter, addr string, n int) { t.Fatalf("unexpected status code: %d. Expecting %d", statusCode, StatusOK) } resultURI := string(body) - if strings.HasPrefix(uri, "https") { - resultURI = uri[:5] + resultURI[4:] - } if resultURI != uri { t.Fatalf("unexpected uri %q. Expecting %q", resultURI, uri) } diff --git a/http.go b/http.go index ab51e36..ba2f880 100644 --- a/http.go +++ b/http.go @@ -861,11 +861,14 @@ var errGetOnly = errors.New("non-GET request received") // // io.EOF is returned if r is closed before reading the first header byte. func (req *Request) ReadLimitBody(r *bufio.Reader, maxBodySize int) error { + req.resetSkipHeader() return req.readLimitBody(r, maxBodySize, false) } func (req *Request) readLimitBody(r *bufio.Reader, maxBodySize int, getOnly bool) error { - req.resetSkipHeader() + // Do not reset the request here - the caller must reset it before + // calling this method. + err := req.Header.Read(r) if err != nil { return err diff --git a/server.go b/server.go index 99d6617..68fabce 100644 --- a/server.go +++ b/server.go @@ -1479,8 +1479,8 @@ func (s *Server) serveConn(c net.Conn) error { } } else { br, err = acquireByteReader(&ctx) - ctx.Request.isTLS = isTLS } + ctx.Request.isTLS = isTLS if err == nil { if s.DisableHeaderNamesNormalizing { diff --git a/server_test.go b/server_test.go index 6d2b075..5019597 100644 --- a/server_test.go +++ b/server_test.go @@ -633,6 +633,15 @@ func TestServerServeTLSEmbed(t *testing.T) { ch := make(chan struct{}) go func() { err := ServeTLSEmbed(ln, certData, keyData, func(ctx *RequestCtx) { + if !ctx.IsTLS() { + ctx.Error("expecting tls", StatusBadRequest) + return + } + scheme := ctx.URI().Scheme() + if string(scheme) != "https" { + ctx.Error(fmt.Sprintf("unexpected scheme=%q. Expecting %q", scheme, "https"), StatusBadRequest) + return + } ctx.WriteString("success") }) if err != nil {