aboutsummaryrefslogtreecommitdiff
path: root/fasthttpadaptor
diff options
context:
space:
mode:
authorGravatar Shawn <kenshao@gmail.com> 2022-12-25 17:07:22 +0800
committerGravatar GitHub <noreply@github.com> 2022-12-25 10:07:22 +0100
commit9b4a7e5bf47a1eb88ae933352a32db983e49abb8 (patch)
tree2793f0343c0e82d276e14f9f8152cfd8a837022f /fasthttpadaptor
parentoptimize: allow http head when use getonly (#1456) (diff)
downloadfasthttp-9b4a7e5bf47a1eb88ae933352a32db983e49abb8.tar.gz
fasthttp-9b4a7e5bf47a1eb88ae933352a32db983e49abb8.tar.bz2
fasthttp-9b4a7e5bf47a1eb88ae933352a32db983e49abb8.zip
fix http2 adapter (#1457)
Diffstat (limited to 'fasthttpadaptor')
-rw-r--r--fasthttpadaptor/adaptor.go2
-rw-r--r--fasthttpadaptor/request.go8
2 files changed, 8 insertions, 2 deletions
diff --git a/fasthttpadaptor/adaptor.go b/fasthttpadaptor/adaptor.go
index 47a4c29..dcd43e4 100644
--- a/fasthttpadaptor/adaptor.go
+++ b/fasthttpadaptor/adaptor.go
@@ -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() {}
diff --git a/fasthttpadaptor/request.go b/fasthttpadaptor/request.go
index cc2684b..d763a98 100644
--- a/fasthttpadaptor/request.go
+++ b/fasthttpadaptor/request.go
@@ -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()