Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JdkRequest does not support compression #258

Open
andreoss opened this issue Jun 27, 2021 · 1 comment
Open

JdkRequest does not support compression #258

andreoss opened this issue Jun 27, 2021 · 1 comment

Comments

@andreoss
Copy link
Collaborator

Add support for gzip and deflate and enable this tests:

@Test
@DisabledIf("isJdkRequest")
final void readsDeflatedJsonResponse() throws Exception {
MatcherAssert.assertThat(
"Must undeflate & parse Json response",
this.request("/deflate")
.fetch()
.as(JsonResponse.class)
.json()
.readObject(),
Matchers.hasEntry(
Matchers.is("deflated"),
Matchers.is(JsonValue.TRUE)
)
);
}

@Test
@DisabledIf("isJdkRequest")
final void readsGzippedJsonResponse() throws Exception {
MatcherAssert.assertThat(
"Must unzip & parse Json response",
this.request("/gzip")
.fetch()
.as(JsonResponse.class)
.json()
.readObject(),
Matchers.hasEntry(
Matchers.is("gzipped"),
Matchers.is(JsonValue.TRUE)
)
);
}

@VivekShahare04
Copy link

@andreoss u mean the request itself does not automatically handle compressed responses (like gzip or deflate).
as a result this can be problematic when the server sends compressed responses, as JdkRequest won't automatically decompress them for you. Am i right?

so we can resolve this in two ways :

  1. Use a Different Request Implementation
  2. Handle Decompression Manually
    but 1 option will be more compatible

Switch to using a request implementation that supports compression. According to the JCabi HTTP documentation, the com.jcabi.http.wire.DecorWire class is specifically designed to handle automatic decompression of responses. You can wrap your JdkRequest instance with DecorWire to enable compression support.

@andreoss i am going to make some changes try to look into it may be it will be helpful.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants