OKAPI-1240: Delete Accept-Encoding and Content-Encoding headers in proxy#1436
OKAPI-1240: Delete Accept-Encoding and Content-Encoding headers in proxy#1436julianladisch wants to merge 2 commits intomasterfrom
Conversation
https://folio-org.atlassian.net/browse/OKAPI-1240 There are four sections when ProxyService proxies a request and response: a) Request from client to Okapi. b) Request from Okapi to module. c) Response from module to Okapi d) Response from Okapi to client. Each section can have a different compression (none, deflate, gzip,br, …). Therefore the compression headers Accept-Encoding and Content-Encoding must not be copied from a) to b) and must not be copied from c) to d). If Accept-Encoding is wrong the client or Okapi may get a body that it cannot decompress resulting in an exception. If Content-Encoding is wrong the decompression of the body fails in Okapi or the client. Fix: Remove the compression headers when copying the headers into the next section.
|
Okapi runs with .setCompressionSupported(true): https://github.com/folio-org/okapi/blob/v7.0.2/okapi-core/src/main/java/org/folio/okapi/MainVerticle.java#L345 Vertx' HttpServer automatically compresses the response body if the client send an Accept-Encoding header: https://vertx.io/docs/vertx-core/java/#_http_compression |
|
And the content is not compressed already. |
adamdickmeiss
left a comment
There was a problem hiding this comment.
Looks good. I think the testing module should not bind to 8081, but the "reserved" ports , such s 9131.
| void test(String contentEncoding1, String contentEncoding2, VertxTestContext vtc) { | ||
| deployOkapi() | ||
| .compose(x -> deployModule(contentEncoding1)) | ||
| .compose(server -> put("http://localhost:8081/foo", null, contentEncoding1)) |
There was a problem hiding this comment.
I think that it would be better to use a port such as 9131 this is in range of "reserved" ports for testing.
Of course, it would be better to get a free port. But that would be a large undertaking (separate PR).
|
Moving to draft because Adam pointed out important aspects:
|



https://folio-org.atlassian.net/browse/OKAPI-1240
There are four sections when ProxyService proxies a request and response:
a) Request from client to Okapi.
b) Request from Okapi to module.
c) Response from module to Okapi
d) Response from Okapi to client.
Each section can have a different compression (none, deflate, gzip,br, …). Therefore the compression headers Accept-Encoding and Content-Encoding must not be copied from a) to b) and must not be copied from c) to d).
If Accept-Encoding is wrong the client or Okapi may get a body that it cannot decompress resulting in an exception.
If Content-Encoding is wrong the decompression of the body fails in Okapi or the client.
Fix: Remove the compression headers when copying the headers into the next section.