wiremock: GZIP compression does not work for responses to POST requests.
Wiremock registers GzipFilter with default configuration:
com.github.tomakehurst.wiremock.jetty9.JettyHttpServer
mockServiceContext.addFilter(GzipFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD));
But by default the aforementioned filter handles only GET request.
org.eclipse.jetty.servlets.GzipFilter
// public void init
tmp=filterConfig.getInitParameter("methods");
if (tmp!=null)
{
StringTokenizer tok = new StringTokenizer(tmp,",",false);
while (tok.hasMoreTokens())
_methods.add(tok.nextToken().trim().toUpperCase(Locale.ENGLISH));
}
else
_methods.add(HttpMethod.GET.asString());
// public void doFilter()
if (!_methods.contains(request.getMethod()) || isExcludedPath(requestURI))
{
super.doFilter(request,response,chain);
return;
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 23 (13 by maintainers)
It should happen automatically provided you’re sending
Accept-Encoding:gzip
in the request.@stelarelas yes, I should have closed this issue ages ago, as it’s been fixed.
It sounds to me like you’re trying to send a non-gzipped request with a gzip header, so I’d expect it to throw an exception in that instance.
@jecklgamis , i did checked-out the wiremock code, did a few modifications then build it locally, to enable gzip-compression on HTTP POST requests… @tomakehurst , could we have it configurable when running wiremock standalone on the next release? Thanks!
Stubs are always loaded uncompressed, then WireMock (well, Jetty’s handler specifically) gzips/gunzips requests and responses.