private WebResponseData webResponseData() throws IOException { List<NameValuePair> responseHeaders = responseHeaders(); int statusCode = (this.response.getRedirectedUrl() != null ? HttpStatus.MOVED_PERMANENTLY.value() : this.response.getStatus()); String statusMessage = statusMessage(statusCode); return new WebResponseData(this.response.getContentAsByteArray(), statusCode, statusMessage, responseHeaders); }
/** * Returns the response headers as a list of {@link NameValuePair}s. * @return the response headers as a list of {@link NameValuePair}s */ public List<NameValuePair> getResponseHeaders() { return responseData_.getResponseHeaders(); }
/** * Returns a new {@link InputStream} allowing to read the downloaded content. * @return the associated InputStream * @throws IOException in case of IO problems */ public InputStream getInputStream() throws IOException { return getStream(downloadedContent_, getResponseHeaders()); }
/** * {@inheritDoc} */ public byte[] getContentAsBytes() { return responseData_.getBody(); }
/** * Returns the status message that was returned from the server. * @return the status message that was returned from the server */ public String getStatusMessage() { return responseData_.getStatusMessage(); }
/** * Returns the status code that was returned by the server. * @return the status code that was returned by the server */ public int getStatusCode() { return responseData_.getStatusCode(); }
/** * Returns the response content as an input stream. * @return the response content as an input stream * @throws IOException in case of IOProblems */ public InputStream getContentAsStream() throws IOException { return responseData_.getInputStream(); }
/** * {@inheritDoc} */ public List<NameValuePair> getResponseHeaders() { return responseData_.getResponseHeaders(); }
/** * Returns a new {@link InputStream} allowing to read the downloaded content. * @return the associated InputStream * @throws IOException in case of IO problems */ public InputStream getInputStream() throws IOException { return getStream(downloadedContent_, getResponseHeaders()); }
/** * {@inheritDoc} */ public byte[] getContentAsBytes() { return responseData_.getBody(); }
/** * {@inheritDoc} */ public String getStatusMessage() { return responseData_.getStatusMessage(); }
/** * {@inheritDoc} */ public int getStatusCode() { return responseData_.getStatusCode(); }
/** * Returns the response content as an input stream. * @return the response content as an input stream * @throws IOException in case of IOProblems */ public InputStream getContentAsStream() throws IOException { return responseData_.getInputStream(); }
@Before public void setup() throws Exception { request = new WebRequest(new URL("http://localhost/")); WebResponseData data = new WebResponseData("".getBytes("UTF-8"), 200, "", Collections.emptyList()); expectedResponse = new WebResponse(data, request, 100L); webConnection = new DelegatingWebConnection(defaultConnection, new DelegateWebConnection(matcher1, connection1), new DelegateWebConnection(matcher2, connection2)); }
/** * {@inheritDoc} */ public List<NameValuePair> getResponseHeaders() { return responseData_.getResponseHeaders(); }
/** * Returns a new {@link InputStream} allowing to read the downloaded content. * @return the associated InputStream */ public InputStream getInputStream() { try { return getStream(downloadedContent_.getInputStream(), getResponseHeaders()); } catch (final IOException e) { throw new RuntimeException(e); // in fact getInputStream should probably have throw declaration } }
/** * {@inheritDoc} */ public byte[] getContentAsBytes() { return responseData_.getBody(); }
/** * {@inheritDoc} */ public String getStatusMessage() { return responseData_.getStatusMessage(); }
/** * {@inheritDoc} */ public int getStatusCode() { return responseData_.getStatusCode(); }
/** * {@inheritDoc} */ public InputStream getContentAsStream() throws IOException { return responseData_.getInputStream(); }