/** * {@inheritDoc} */ public byte[] getContentAsBytes() { return responseData_.getBody(); }
/** * {@inheritDoc} */ public byte[] getContentAsBytes() { return responseData_.getBody(); }
/** * {@inheritDoc} */ public byte[] getContentAsBytes() { return responseData_.getBody(); }
/** * {@inheritDoc} */ public InputStream getContentAsStream() throws IOException { final byte[] body = responseData_.getBody(); if (body != null) { return new ByteArrayInputStream(body); } return null; }
/** * {@inheritDoc} */ public InputStream getContentAsStream() throws IOException { final byte[] body = responseData_.getBody(); if (body != null) { return new ByteArrayInputStream(body); } return null; }
/** * Constructs with a data stream to minimize copying of the entire body. * * @param bodyStream Stream of this response's body * @param statusCode Status code from the server * @param statusMessage Status message from the server * @param responseHeaders Headers in this response * * @throws IOException on stream errors */ public WebResponseData(final InputStream bodyStream, final int statusCode, final String statusMessage, final List<NameValuePair> responseHeaders) throws IOException { statusCode_ = statusCode; statusMessage_ = statusMessage; responseHeaders_ = Collections.unmodifiableList(responseHeaders); body_ = getBody(bodyStream, responseHeaders); }
/** * Constructs with a data stream to minimize copying of the entire body. * * @param bodyStream Stream of this response's body * @param statusCode Status code from the server * @param statusMessage Status message from the server * @param responseHeaders Headers in this response * * @throws IOException on stream errors */ public WebResponseData(final InputStream bodyStream, final int statusCode, final String statusMessage, final List<NameValuePair> responseHeaders) throws IOException { statusCode_ = statusCode; statusMessage_ = statusMessage; responseHeaders_ = Collections.unmodifiableList(responseHeaders); body_ = getBody(bodyStream, responseHeaders); }
/** * {@inheritDoc} */ public String getContentAsString(final String encoding) { final byte[] body = responseData_.getBody(); if (body != null) { try { return new String(body, encoding); } catch (final UnsupportedEncodingException e) { LOG.warn("Attempted to use unsupported encoding '" + encoding + "'; using default system encoding."); return new String(body); } } return null; }
/** * {@inheritDoc} */ public String getContentAsString(final String encoding) { final byte[] body = responseData_.getBody(); if (body != null) { try { return new String(body, encoding); } catch (final UnsupportedEncodingException e) { LOG.warn("Attempted to use unsupported encoding '" + encoding + "'; using default system encoding."); return new String(body); } } return null; }
/** * {@inheritDoc} */ public String getContentAsString(final String encoding) { final byte[] body = responseData_.getBody(); if (body != null) { try { return new String(body, encoding); } catch (final UnsupportedEncodingException e) { LOG.warn("Attempted to use unsupported encoding '" + encoding + "'; using default system encoding."); return new String(body); } } return null; }
/** * Constructs with a raw byte[] (mostly for testing). * * @param body Body of this response * @param statusCode Status code from the server * @param statusMessage Status message from the server * @param responseHeaders Headers in this response */ public WebResponseData(final byte[] body, final int statusCode, final String statusMessage, final List<NameValuePair> responseHeaders) { statusCode_ = statusCode; statusMessage_ = statusMessage; responseHeaders_ = Collections.unmodifiableList(responseHeaders); if (body != null) { try { body_ = getBody(new ByteArrayInputStream(body), responseHeaders); } catch (final IOException e) { body_ = body; } } }
/** * Constructs with a raw byte[] (mostly for testing). * * @param body Body of this response * @param statusCode Status code from the server * @param statusMessage Status message from the server * @param responseHeaders Headers in this response */ public WebResponseData(final byte[] body, final int statusCode, final String statusMessage, final List<NameValuePair> responseHeaders) { statusCode_ = statusCode; statusMessage_ = statusMessage; responseHeaders_ = Collections.unmodifiableList(responseHeaders); if (body != null) { try { body_ = getBody(new ByteArrayInputStream(body), responseHeaders); } catch (final IOException e) { body_ = body; } } }