Skip to content

Commit

Permalink
fix http2 adapter (#1457)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedia committed Dec 25, 2022
1 parent c637221 commit 9b4a7e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions fasthttpadaptor/adaptor.go
Expand Up @@ -109,3 +109,5 @@ func (w *netHTTPResponseWriter) WriteHeader(statusCode int) {
func (w *netHTTPResponseWriter) Write(p []byte) (int, error) {
return w.w.Write(p)
}

func (w *netHTTPResponseWriter) Flush() {}
8 changes: 6 additions & 2 deletions fasthttpadaptor/request.go
Expand Up @@ -25,8 +25,12 @@ func ConvertRequest(ctx *fasthttp.RequestCtx, r *http.Request, forServer bool) e
}

r.Method = b2s(ctx.Method())
r.Proto = "HTTP/1.1"
r.ProtoMajor = 1
r.Proto = b2s(ctx.Request.Header.Protocol())
if r.Proto == "HTTP/2" {
r.ProtoMajor = 2
} else {
r.ProtoMajor = 1
}
r.ProtoMinor = 1
r.ContentLength = int64(len(body))
r.RemoteAddr = ctx.RemoteAddr().String()
Expand Down

0 comments on commit 9b4a7e5

Please sign in to comment.