Package org.jsoup.helper

## Class HttpConnection.Response

- java.lang.Object
- - org.jsoup.helper.HttpConnection.Response

All Implemented Interfaces:
  `Connection.Base<Connection.Response>`, `Connection.Response`

Enclosing class:
  HttpConnection

    public static class HttpConnection.Response
    extends java.lang.Object
    implements Connection.Response

### Method Summary

All Methods Instance Methods Concrete Methods
`java.lang.String` `body()` Get the body of the response as a plain string.
`byte[]` `bodyAsBytes()` Get the body of the response as an array of bytes.
`java.io.BufferedInputStream` `bodyStream()` Get the body of the response as a (buffered) InputStream.
`Connection.Response` `bufferUp()` Read the body of the response into a local buffer, so that `Connection.Response.parse()` may be called repeatedly on the same connection response (otherwise, once the response is read, its InputStream will have been drained and may not be re-read).
`java.lang.String` `charset()` Get the character set name of the response, derived from the content-type header.
`HttpConnection.Response` `charset​(java.lang.String charset)` Set / override the response character set.
`java.lang.String` `contentType()` Get the response content type (e.g.
`Document` `parse()` Read and parse the body of the response as a Document.
`int` `statusCode()` Get the status code of the response.
`java.lang.String` `statusMessage()` Get the status message of the response.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.jsoup.Connection.Base

`addHeader, cookie, cookie, cookies, hasCookie, hasHeader, hasHeaderWithValue, header, header, headers, headers, method, method, multiHeaders, removeCookie, removeHeader, url, url`

### Method Detail

#### statusCode

    public int statusCode()

Description copied from interface: `Connection.Response`
Get the status code of the response.

Specified by:
  `statusCode` in interface `Connection.Response`
Returns:
  status code

#### statusMessage

    public java.lang.String statusMessage()

Description copied from interface: `Connection.Response`
Get the status message of the response.

Specified by:
  `statusMessage` in interface `Connection.Response`
Returns:
  status message

#### charset

    public java.lang.String charset()

Description copied from interface: `Connection.Response`
Get the character set name of the response, derived from the content-type header.

Specified by:
  `charset` in interface `Connection.Response`
Returns:
  character set name if set, null if not

#### charset

    public HttpConnection.Response charset​(java.lang.String charset)

Description copied from interface: `Connection.Response`
Set / override the response character set. When the document body is parsed it will be with this charset.

Specified by:
  `charset` in interface `Connection.Response`
Parameters:
  `charset` - to decode body as
Returns:
  this Response, for chaining

#### contentType

    public java.lang.String contentType()

Description copied from interface: `Connection.Response`
Get the response content type (e.g. "text/html");

Specified by:
  `contentType` in interface `Connection.Response`
Returns:
  the response content type, or null if one was not set

#### parse

    public Document parse()
                   throws java.io.IOException

Description copied from interface: `Connection.Response`
Read and parse the body of the response as a Document. If you intend to parse the same response multiple times, you should `Connection.Response.bufferUp()` first.

Specified by:
  `parse` in interface `Connection.Response`
Returns:
  a parsed Document
Throws:
  `java.io.IOException` - on error

#### body

    public java.lang.String body()

Description copied from interface: `Connection.Response`
Get the body of the response as a plain string.

Specified by:
  `body` in interface `Connection.Response`
Returns:
  body

#### bodyAsBytes

    public byte[] bodyAsBytes()

Description copied from interface: `Connection.Response`
Get the body of the response as an array of bytes.

Specified by:
  `bodyAsBytes` in interface `Connection.Response`
Returns:
  body bytes

#### bufferUp

    public Connection.Response bufferUp()

Description copied from interface: `Connection.Response`
Read the body of the response into a local buffer, so that `Connection.Response.parse()` may be called repeatedly on the same connection response (otherwise, once the response is read, its InputStream will have been drained and may not be re-read). Calling `Connection.Response.body()` or `Connection.Response.bodyAsBytes()` has the same effect.

Specified by:
  `bufferUp` in interface `Connection.Response`
Returns:
  this response, for chaining

#### bodyStream

    public java.io.BufferedInputStream bodyStream()

Description copied from interface: `Connection.Response`
Get the body of the response as a (buffered) InputStream. You should close the input stream when you're done with it. Other body methods (like bufferUp, body, parse, etc) will not work in conjunction with this method.

This method is useful for writing large responses to disk, without buffering them completely into memory first.

Specified by:
  `bodyStream` in interface `Connection.Response`
Returns:
  the response body input stream