web stats
Http sender failed to parse http Entity into string - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 11-01-2016, 07:29 PM
My.Cymbidum My.Cymbidum is offline
What's HL7?
Join Date: Aug 2011
Posts: 4
My.Cymbidum is on a distinguished road
Default Http sender failed to parse http Entity into string

I got a `IoException` When I try to parse http Entity from a ASP.NET api into string.

  String responseBody = IOUtils.toString(httpResponse.getEntity().getContent(), responseCharset)
String responseBody =EntityUtils.toString((httpResponse.getEntity());

I try to do it by using these two method.They all works fine except the **ASP.NET api**,which can be requested normally with Postman.

I got the function which throw the exception when run at 'while' the second time.

 public static long copyLarge(InputStream input, OutputStream output, byte[] buffer)  throws IOException {
            long count = 0;
            int n = 0;
            while (EOF != (n = input.read(buffer))) {
                output.write(buffer, 0, n);
                count += n;
            return count;
The stack as follows:

> Premature end of chunk coded message body: closing chunk expected at
> org.apache.http.impl.io.ChunkedInputStream.getChun kSize(ChunkedInputStream.java:268)
> at
> org.apache.http.impl.io.ChunkedInputStream.nextChu nk(ChunkedInputStream.java:227)
> at
> org.apache.http.impl.io.ChunkedInputStream.read(Ch unkedInputStream.java:186)
> at
> org.apache.http.conn.EofSensorInputStream.read(Eof SensorInputStream.java:137)
> at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.j ava:284) at
> sun.nio.cs.StreamDecoder.implRead(StreamDecoder.ja va:326) at
> sun.nio.cs.StreamDecoder.read(StreamDecoder.java:1 78) at
> java.io.InputStreamReader.read(InputStreamReader.j ava:184) at
> java.io.Reader.read(Reader.java:140) at
> org.apache.commons.io.IOUtils.copyLarge(IOUtils.ja va:1928) at
> org.apache.commons.io.IOUtils.copyLarge(IOUtils.ja va:1907) at
> org.apache.commons.io.IOUtils.copy(IOUtils.java:18 84) at
> org.apache.commons.io.IOUtils.copy(IOUtils.java:18 34) at
> org.apache.commons.io.IOUtils.toString(IOUtils.jav a:705)

**The second way also failed when try to read buffer from a EofSensorInputStream**

version:3.4.2 jdk:1.8.0_65

Thanks in advance!
Reply With Quote

.net, http sender, ioexception

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -8. The time now is 06:08 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation