mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
Properly set "https" scheme in RequestCtx.URI() for TLS connections
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user