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

Cannot decode a response with CHUNKED encoding #131

Open
EugeneHryz opened this issue Aug 6, 2024 · 0 comments · May be fixed by #132
Open

Cannot decode a response with CHUNKED encoding #131

EugeneHryz opened this issue Aug 6, 2024 · 0 comments · May be fixed by #132

Comments

@EugeneHryz
Copy link

EugeneHryz commented Aug 6, 2024

Version: 2.5.1

When application receives a response with header Transfer-Encoding: chunked, then HAPI is unable to decode it.
Here is the exception:

ca.uhn.hl7v2.hoh.api.DecodeException: Failed to decode CHUNKED encoding
	at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.readBytesChunked(AbstractHl7OverHttpDecoder.java:249)
	at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.doReadContentsFromInputStreamAndDecode(AbstractHl7OverHttpDecoder.java:222)
	at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.readHeadersAndContentsFromInputStreamAndDecode(AbstractHl7OverHttpDecoder.java:537)
	at ca.uhn.hl7v2.hoh.raw.client.AbstractRawClient.doSendAndReceiveInternal(AbstractRawClient.java:159)
	at ca.uhn.hl7v2.hoh.raw.client.AbstractRawClient.sendAndReceive(AbstractRawClient.java:279)
	at ca.uhn.hl7v2.hoh.raw.client.HohRawClientSimple.sendAndReceive(HohRawClientSimple.java:55)
	at ca.uhn.hl7v2.hoh.hapi.client.AbstractClient.sendAndReceiveMessage(AbstractClient.java:161)
	...
	...
Caused by: java.net.SocketException: Received EOF from input stream
	at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.readLine(AbstractHl7OverHttpDecoder.java:580)
	at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.readLine(AbstractHl7OverHttpDecoder.java:543)
	at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.readBytesChunked(AbstractHl7OverHttpDecoder.java:247)

I think the issue is in the class AbstractHl7OverHttpDecoder in method readBytesChunked(InputStream). It seems it reads the length of the first chunk, and then instead of reading just that amount of bytes, it reads the whole response body. And when it tries to read the length of second chunk, the stream has already been read (Receives EOF of stream).

@EugeneHryz EugeneHryz linked a pull request Aug 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant