1

I have encountered a strange case. I am working with a Spring Boot application which consists of a few different services.

For each service, in a application.properties file, those properties were added:

server.compression.enabled=true
server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,application/javascript,text/css
server.compression.min-response-size=1024

Now, it should work that every appropriate request contains "Accept-Encoding" header and response contains "Content-Encoding" header, and the response should be compressed.

It it almost works like that, but for one service POST responses do not contain "Content-Encoding", even though POST requests contain "Accept-Encoding". Such responses are not compressed, so it's not only about missing headers. GET responses/requests for this service work fine. Both GET/POST requests/responses for the rest of services work fine too.

This particular service's Spring Boot version is 1.5.16.RELEASE.

Where should I look for the cause? Can this setting be overwritten somehow for POST responses only?

Update: I also noticed that in POST responses for this service, "Vary: Accept-Encoding" header is missing. It's present in all other cases.

Mr P
  • 149
  • 1
  • 12
  • Please add which Spring Boot version you are using. – M. Deinum Sep 17 '19 at 10:34
  • 1.5.16.RELEASE. – Mr P Sep 17 '19 at 11:10
  • Is the request containing one of the mime-types that supports compression? And is the response larger then 1024 bytes? – M. Deinum Sep 17 '19 at 11:12
  • Yes, request headers: Content-Type: application/json;charset=utf-8 and yes, it's megabytes even sometimes – Mr P Sep 17 '19 at 11:22
  • But is the result also one of the mim-types that is supported? Because that is what is the important part here, it is more or less the `Accept-Header` and not so much the incoming `Content-Type` header that is import. It is the resulting content type that matters. – M. Deinum Sep 17 '19 at 11:24
  • OK, so it looks like this: Request Accept-Header: application/json, text/plain, */*; Response Content-Type-Header: application/json;charset=utf-8. It's for both GETs and POSTs like that – Mr P Sep 17 '19 at 11:46
  • RFC 1867 Form-based File Upload in HTML ... 5.1 Compression, encryption This scheme doesn't address the possible compression of files. – Phillip Williams Sep 19 '19 at 00:49
  • that being said, it does not preclude the content mine type specification and a helper on the server that decodes the content before the the server script receives it. – Phillip Williams Sep 19 '19 at 00:55
  • Solution found, thanks y'all. – Mr P Sep 19 '19 at 09:07

1 Answers1

0

Try to change wiremock dependency configuration from compile to testCompile. In my case, wiremock in 2.22.0 version (with compile) caused this issue.

Klaudia
  • 26
  • 3