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

Reduce body allocation and copying #475

Merged
merged 7 commits into from
Feb 4, 2019
Merged

Reduce body allocation and copying #475

merged 7 commits into from
Feb 4, 2019

Conversation

nilern
Copy link
Contributor

@nilern nilern commented Jan 29, 2019

Removes various intermediate byte arrays and strings in body decoding that were unnecessary. JSON and Transit decoding get the most benefit.

I didn't have time to figure out every format and it seems that some of them would need changes to other libraries like ring.util.codec. dakrone/cheshire#139 would also enable a bit more gains for JSON decoding.

@dakrone dakrone merged commit 3083aa5 into dakrone:3.x Feb 4, 2019
@ecolui
Copy link

ecolui commented May 2, 2019

Greetings - we recently upgraded to clj-http 3.10.0. The following doesn't work in 3.10.0, but it worked in 3.9.1. In 3.10.0, we get a java.io.IOException Stream Closed error
(client/get "https://some-site.com/myresource"
{:basic-auth ["user" "pass"]
:accept :json
:as :json
:coerce :always
:throw-exceptions false})

If we remove :as :json, we don't get that error, but the body isn't coerced to a clj map. I'm planning on looking through changes leading up to 3.10.0, but before I did that, I figured that I'd post the error for early awareness.

@dakrone
Copy link
Owner

dakrone commented May 2, 2019

I opened #489 for this @ecolui, I'll see if I can reproduce it.

rymndhng added a commit that referenced this pull request Sep 27, 2020
Connections are not closing immediately after coercing the body using transit.
This is a regression introduced in #475.
Previously, the response body always was also transferred into an intermediate
byte-array which will read bytes until the stream is empty, and automatically
close the connection.

Since we no longer have this implicit behavior, the body coercion middleware
must close the inputstream after reading a value.

Fixes #564
rymndhng added a commit that referenced this pull request Nov 15, 2020
Connections are not closing immediately after coercing the body using transit.
This is a regression introduced in #475.
Previously, the response body always was also transferred into an intermediate
byte-array which will read bytes until the stream is empty, and automatically
close the connection.

Since we no longer have this implicit behavior, the body coercion middleware
must close the inputstream after reading a value.

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

Successfully merging this pull request may close these issues.

3 participants