Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix adapter support http2 #1457

Merged
merged 1 commit into from Dec 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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