public static class

HttpConnection.Response

extends Object
implements Connection.Base<T extends Base> Connection.Response
java.lang.Object
   ↳ org.jsoup.helper.HttpConnection.Response

Summary

Public Methods
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.
String charset()
Get the character set name of the response.
String contentType()
Get the response content type (e.g.
T extends Base cookie(String name, String value)
Set a cookie in this request/response.
String cookie(String name)
Get a cookie value by name from this request/response.
Map<StringString> cookies()
Retrieve all of the request/response cookies as a map
boolean hasCookie(String name)
Check if a cookie is present
boolean hasHeader(String name)
Check if a header is present
T extends Base header(String name, String value)
Set a header.
String header(String name)
Get the value of a header.
Map<StringString> headers()
Retrieve all of the request/response headers as a map
Connection.Method method()
Get the request method
T extends Base method(Connection.Method method)
Set the request method
Document parse()
Parse the body of the response as a Document.
T extends Base removeCookie(String name)
Remove a cookie by name
T extends Base removeHeader(String name)
Remove a header by name
int statusCode()
Get the status code of the response.
String statusMessage()
Get the status message of the response.
URL url()
Get the URL
T extends Base url(URL url)
Set the URL
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.jsoup.Connection.Base
From interface org.jsoup.Connection.Response

Public Methods

public String body ()

Get the body of the response as a plain string.

Returns
  • body

public byte[] bodyAsBytes ()

Get the body of the response as an array of bytes.

Returns
  • body bytes

public String charset ()

Get the character set name of the response.

Returns
  • character set name

public String contentType ()

Get the response content type (e.g. "text/html");

Returns
  • the response content type

public T extends Base cookie (String name, String value)

Set a cookie in this request/response.

Parameters
name name of cookie
value value of cookie
Returns
  • this, for chianing

public String cookie (String name)

Get a cookie value by name from this request/response.

Response objects have a simplified cookie model. Each cookie set in the response is added to the response object's cookie key=value map. The cookie's path, domain, and expiry date are ignored.

Parameters
name name of cookie to retrieve.
Returns
  • value of cookie, or null if not set

public Map<StringString> cookies ()

Retrieve all of the request/response cookies as a map

Returns
  • cookies

public boolean hasCookie (String name)

Check if a cookie is present

Parameters
name name of cookie
Returns
  • if the cookie is present in this request/response

public boolean hasHeader (String name)

Check if a header is present

Parameters
name name of header (case insensitive)
Returns
  • if the header is present in this request/response

public T extends Base header (String name, String value)

Set a header. This method will overwrite any existing header with the same case insensitive name.

Parameters
name Name of header
value Value of header
Returns
  • this, for chaining

public String header (String name)

Get the value of a header. This is a simplified header model, where a header may only have one value.

Header names are case insensitive.

Parameters
name name of header (case insensitive)
Returns
  • value of header, or null if not set.

public Map<StringString> headers ()

Retrieve all of the request/response headers as a map

Returns
  • headers

public Connection.Method method ()

Get the request method

Returns
  • method

public T extends Base method (Connection.Method method)

Set the request method

Parameters
method new method
Returns
  • this, for chaining

public Document parse ()

Parse the body of the response as a Document.

Returns
  • a parsed Document
Throws
IOException

public T extends Base removeCookie (String name)

Remove a cookie by name

Parameters
name name of cookie to remove
Returns
  • this, for chianing

public T extends Base removeHeader (String name)

Remove a header by name

Parameters
name name of header to remove (case insensitive)
Returns
  • this, for chianing

public int statusCode ()

Get the status code of the response.

Returns
  • status code

public String statusMessage ()

Get the status message of the response.

Returns
  • status message

public URL url ()

Get the URL

Returns
  • URL

public T extends Base url (URL url)

Set the URL

Parameters
url new URL
Returns
  • this, for chaining