twitter4j

## Class HttpResponse

- java.lang.Object
- - twitter4j.HttpResponse

Direct Known Subclasses:
  HttpResponseImpl

    public abstract class HttpResponse
    extends Object

A data class representing HTTP Response

Author:
  Yusuke Yamamoto - yusuke at mac.com

### Constructor Summary

Constructors
Constructor and Description
`HttpResponse(HttpClientConfiguration conf)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`JSONArray` `asJSONArray()` Returns the response body as twitter4j.JSONArray. Disconnects the internal HttpURLConnection silently.
`JSONObject` `asJSONObject()` Returns the response body as twitter4j.JSONObject. Disconnects the internal HttpURLConnection silently.
`Reader` `asReader()`
`InputStream` `asStream()` Returns the response stream. This method cannot be called after calling asString() or asDcoument() It is suggested to call disconnect() after consuming the stream.
`String` `asString()` Returns the response body as string. Disconnects the internal HttpURLConnection silently.
`abstract void` `disconnect()`
`abstract String` `getResponseHeader(String name)`
`abstract Map<String,List<String>>` `getResponseHeaderFields()`
`int` `getStatusCode()`
`String` `toString()`

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

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### HttpResponse

    public HttpResponse(HttpClientConfiguration conf)

### Method Detail

#### getStatusCode

    public int getStatusCode()

#### getResponseHeader

    public abstract String getResponseHeader(String name)

#### getResponseHeaderFields

    public abstract Map<String,List<String>> getResponseHeaderFields()

#### asStream

    public InputStream asStream()

Returns the response stream.
This method cannot be called after calling asString() or asDcoument()
It is suggested to call disconnect() after consuming the stream.

Disconnects the internal HttpURLConnection silently.

Returns:
  response body stream
See Also:
  `disconnect()`

#### asString

    public String asString()
                    throws TwitterException

Returns the response body as string.
Disconnects the internal HttpURLConnection silently.

Returns:
  response body
Throws:
  `TwitterException` - when there is any network issue upon response body consumption

#### asJSONObject

    public JSONObject asJSONObject()
                            throws TwitterException

Returns the response body as twitter4j.JSONObject.
Disconnects the internal HttpURLConnection silently.

Returns:
  response body as twitter4j.JSONObject
Throws:
  `TwitterException` - when the response body is not in JSON Object format

#### asJSONArray

    public JSONArray asJSONArray()
                          throws TwitterException

Returns the response body as twitter4j.JSONArray.
Disconnects the internal HttpURLConnection silently.

Returns:
  response body as twitter4j.JSONArray
Throws:
  `TwitterException` - when the response body is not in JSON Array format

#### asReader

    public Reader asReader()

#### disconnect

    public abstract void disconnect()
                             throws IOException

Throws:
  `IOException`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`