Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
NewHandler wraps http handler to support compression for both requests and responses.
func NewRequestHandler ¶
NewRequestHandler return handler, which transparently decodes http requests which are using either gzip or deflate algorithm. Request should have Content-Encoding header set to the appropriate value. If content encoding is recognised, request body will be transparently uncompressed in the passed handler h and Content-Encoding header removed. No decoding errors are handled by the wrapper and they're all available through the regular request body read call.
If content encoding is outside of the supported types, the request will be passed unaltered.
func NewResponseHandler ¶
NewResponseHandler returns handler which transparently compresses response written by passed handler h. The compression algorithm is being chosen accordingly to the value of Accept-Encoding header: both gzip and deflate are supported, with gzip taking precedence if both are present.
If WriteHeader is called on the handler compression is disabled. This is to avoid sending empty archives or compressing small error responses.
The returned handler preserves http.CloseNotifier, http.Hijacker and http.Flusher implementation of h, if any.
Types ¶
This section is empty.