[server] Use a FastHTTP contexts pool for Go HTTP bridging.
This commit is contained in:
parent
b6802d47fe
commit
ecdca8ab72
1 changed files with 11 additions and 2 deletions
|
@ -487,7 +487,13 @@ func (_server *server) ServeHTTP (_response http.ResponseWriter, _request *http.
|
||||||
|
|
||||||
// FIXME: Reimplemnet this to eliminate the HTTP-encode-followed-by-HTTP-decode!
|
// FIXME: Reimplemnet this to eliminate the HTTP-encode-followed-by-HTTP-decode!
|
||||||
|
|
||||||
_context := fasthttp.RequestCtx {}
|
var _context *fasthttp.RequestCtx
|
||||||
|
if _context_0 := _requestContextsPool.Get (); _context_0 != nil {
|
||||||
|
_context = _context_0.(*fasthttp.RequestCtx)
|
||||||
|
} else {
|
||||||
|
_context = new (fasthttp.RequestCtx)
|
||||||
|
}
|
||||||
|
defer _requestContextsPool.Put (_context)
|
||||||
|
|
||||||
_context.Request.Reset ()
|
_context.Request.Reset ()
|
||||||
_context.Request.Header.SetMethod (_request.Method)
|
_context.Request.Header.SetMethod (_request.Method)
|
||||||
|
@ -495,7 +501,7 @@ func (_server *server) ServeHTTP (_response http.ResponseWriter, _request *http.
|
||||||
|
|
||||||
_context.Response.Reset ()
|
_context.Response.Reset ()
|
||||||
|
|
||||||
_server.Serve (&_context)
|
_server.Serve (_context)
|
||||||
|
|
||||||
_responseHeaders := _response.Header ()
|
_responseHeaders := _response.Header ()
|
||||||
_responseHeaders["Date"] = nil
|
_responseHeaders["Date"] = nil
|
||||||
|
@ -521,6 +527,9 @@ func (_server *server) ServeHTTP (_response http.ResponseWriter, _request *http.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var _requestContextsPool sync.Pool
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func (_server *server) Printf (_format string, _arguments ... interface{}) () {
|
func (_server *server) Printf (_format string, _arguments ... interface{}) () {
|
||||||
|
|
Loading…
Reference in a new issue