@Override public void writeTo(final OutputStream outstream) throws IOException { wrappedEntity.writeTo(outstream); }
@Override public void writeTo(final OutputStream outstream) throws IOException { consumed = true; original.writeTo(outstream); }
@Override public void writeTo(final OutputStream outstream) throws IOException { Args.notNull(outstream, "Output stream"); final GZIPOutputStream gzip = new GZIPOutputStream(outstream); wrappedEntity.writeTo(gzip); // Only close output stream if the wrapped entity has been // successfully written out gzip.close(); }
private static byte[] httpEntityToBytes(HttpEntity httpEntity) throws ConnectionException { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { httpEntity.writeTo(out); out.flush(); } catch (IOException e) { throw new ConnectionException("httpEntityToBytes", e); } return out.toByteArray(); }
@Override public void writeTo(final OutputStream outstream) throws IOException { try { this.wrappedEntity.writeTo(outstream); releaseConnection(); } finally { cleanup(); } }
@Override public void sendRequestEntity(final HttpEntityEnclosingRequest request) throws HttpException, IOException { Args.notNull(request, "HTTP request"); ensureOpen(); final HttpEntity entity = request.getEntity(); if (entity == null) { return; } final OutputStream outstream = prepareOutput(request); entity.writeTo(outstream); outstream.close(); }
@Override public void sendResponseEntity(final HttpResponse response) throws HttpException, IOException { Args.notNull(response, "HTTP response"); ensureOpen(); final HttpEntity entity = response.getEntity(); if (entity == null) { return; } final OutputStream outstream = prepareOutput(response); entity.writeTo(outstream); outstream.close(); }
/** * Writes out the content of the given HTTP entity to the session output * buffer based on properties of the given HTTP message. * * @param outbuffer the output session buffer. * @param message the HTTP message. * @param entity the HTTP entity to be written out. * @throws HttpException in case of HTTP protocol violation. * @throws IOException in case of an I/O error. */ public void serialize( final SessionOutputBuffer outbuffer, final HttpMessage message, final HttpEntity entity) throws HttpException, IOException { Args.notNull(outbuffer, "Session output buffer"); Args.notNull(message, "HTTP message"); Args.notNull(entity, "HTTP entity"); final OutputStream outstream = doSerialize(outbuffer, message); entity.writeTo(outstream); outstream.close(); }
protected String loadUrlBody(String address) { HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = null; String responseString = null; try { response = httpclient.execute(new HttpGet(address)); StatusLine statusLine = response.getStatusLine(); if(statusLine.getStatusCode() == HttpStatus.SC_OK){ ByteArrayOutputStream out = new ByteArrayOutputStream(); response.getEntity().writeTo(out); out.close(); responseString = out.toString(); } else{ response.getEntity().getContent().close(); throw new IOException(statusLine.getReasonPhrase()); } } catch (ClientProtocolException e) { } catch (IOException e) { } return responseString; }
try { if (entity != null) { entity.writeTo(entityDigester);