Java Code Examples for org.apache.http.HttpEntity#isStreaming()
The following examples show how to use
org.apache.http.HttpEntity#isStreaming() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpUtil.java From neembuu-uploader with GNU General Public License v3.0 | 6 votes |
private static ReadableByteChannel wrap(final InputStream is, final HttpEntity he, final Content c, final double contentLength){ return new ReadableByteChannel() { double total = 0; @Override public int read(ByteBuffer dst) throws IOException { byte[]b=new byte[dst.capacity()]; int r = is.read(b); //this sleep is just to slow down update to see, if the UI is working or not ! // NU's update is very very very fast //try{Thread.sleep(1000);}catch(Exception a){} dst.put(b,0,r); total+=r; c.setProgress(total/contentLength); return r; } @Override public boolean isOpen() { return he.isStreaming(); } @Override public void close() throws IOException { is.close(); } }; }
Example 2
Source File: FDSHttpClient.java From galaxy-fds-sdk-java with Apache License 2.0 | 5 votes |
public void closeResponseEntity(HttpResponse response) { if (response == null) return; HttpEntity entity = response.getEntity(); if (entity != null && entity.isStreaming()) try { entity.getContent().close(); } catch (IOException e) { LOG.error(formatErrorMsg("close response entity", e)); } }
Example 3
Source File: BceHttpResponse.java From bce-sdk-java with Apache License 2.0 | 5 votes |
public BceHttpResponse(CloseableHttpResponse httpResponse) throws IOException { this.httpResponse = httpResponse; HttpEntity entity = httpResponse.getEntity(); if (entity != null && entity.isStreaming()) { this.content = entity.getContent(); } }
Example 4
Source File: SdsTHttpClient.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
/** * copy from org.apache.http.util.EntityUtils#consume. Android has it's own httpcore that doesn't * have a consume. */ private static void consume(final HttpEntity entity) throws IOException { if (entity == null) { return; } if (entity.isStreaming()) { InputStream instream = entity.getContent(); if (instream != null) { instream.close(); } } }
Example 5
Source File: GalaxyHttpClient.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
/** * copy from org.apache.http.util.EntityUtils#consume. Android has it's own httpcore that doesn't * have a consume. */ private static void consume(final HttpEntity entity) throws IOException { if (entity == null) { return; } if (entity.isStreaming()) { InputStream instream = entity.getContent(); if (instream != null) { instream.close(); } } }
Example 6
Source File: BaseClient.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
protected static void closeResponseEntity(HttpResponse response) { if (response == null) return; HttpEntity entity = response.getEntity(); if (entity != null && entity.isStreaming()) try { entity.getContent().close(); } catch (IOException e) { LOG.error("close response entity", e); } }
Example 7
Source File: MetricsHttpClient.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
/** * copy from org.apache.http.util.EntityUtils#consume. Android has it's own httpcore that doesn't * have a consume. */ private static void consume(final HttpEntity entity) throws IOException { if (entity == null) { return; } if (entity.isStreaming()) { InputStream instream = entity.getContent(); if (instream != null) { instream.close(); } } }
Example 8
Source File: TalosHttpClient.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
/** * copy from org.apache.http.util.EntityUtils#consume. Android has it's own httpcore that doesn't * have a consume. */ private static void consume(final HttpEntity entity) throws IOException { if (entity == null) { return; } if (entity.isStreaming()) { InputStream instream = entity.getContent(); if (instream != null) { instream.close(); } } }
Example 9
Source File: THttpClient.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
/** * copy from org.apache.http.util.EntityUtils#consume. Android has it's own httpcore * that doesn't have a consume. */ private static void consume(final HttpEntity entity) throws IOException { if (entity == null) { return; } if (entity.isStreaming()) { InputStream instream = entity.getContent(); if (instream != null) { instream.close(); } } }
Example 10
Source File: EntityUtils.java From RoboZombie with Apache License 2.0 | 5 votes |
/** * Ensures that the entity content is fully consumed and the content stream, if exists, * is closed. * * @param entity * @throws IOException if an error occurs reading the input stream * * @since 4.1 */ public static void consume(final HttpEntity entity) throws IOException { if (entity == null) { return; } if (entity.isStreaming()) { InputStream instream = entity.getContent(); if (instream != null) { instream.close(); } } }