com.thetransactioncompany.jsonrpc2.client
Class RawResponse

java.lang.Object
  extended by com.thetransactioncompany.jsonrpc2.client.RawResponse

public class RawResponse
extends Object

Represents the raw HTTP response to a JSON-RPC 2.0 request or notification. Can be used to retrieve the unparsed response content and headers.

Since:
1.6
Author:
Vladimir Dzhuvinov

Method Summary
 String getContent()
          Returns the raw response content.
 String getContentEncoding()
          Returns the value of the "Content-Encoding" header field.
 int getContentLength()
          Returns the value of the "Content-Length" header field.
 String getContentType()
          Returns the value of the "Content-Type" header field.
 String getHeaderField(String name)
          Returns the value of the named header field.
 Map<String,List<String>> getHeaderFields()
          Returns an unmodifiable Map of the header fields.
 int getStatusCode()
          Gets the status code from the HTTP response message, e.g.
 String getStatusMessage()
          Gets the HTTP response status message, if any, returned along with the status code from a server.
protected static RawResponse parse(HttpURLConnection connection)
          Parses the raw HTTP response from the specified URL connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parse

protected static RawResponse parse(HttpURLConnection connection)
                            throws IOException
Parses the raw HTTP response from the specified URL connection.

Parameters:
connection - The URL connection, must be in state completed and not null.
Throws:
IOException - If the response content couldn't be read.

getStatusCode

public int getStatusCode()
Gets the status code from the HTTP response message, e.g. 200 on success.

Returns:
The HTTP status code, or -1.

getStatusMessage

public String getStatusMessage()
Gets the HTTP response status message, if any, returned along with the status code from a server.

Returns:
The HTTP status message, or null.

getContent

public String getContent()
Returns the raw response content.

Returns:
The raw content.

getHeaderFields

public Map<String,List<String>> getHeaderFields()
Returns an unmodifiable Map of the header fields. The Map keys are Strings that represent the response header field names. Each Map value is an unmodifiable List of Strings that represents the corresponding field values.

Returns:
A Map of the header fields.

getHeaderField

public String getHeaderField(String name)
Returns the value of the named header field. If called on a connection that sets the same header multiple times with possibly different values, only the last value is returned.

Parameters:
name - The name of the header.
Returns:
The value of the named header field, null if there is no such field in the header.

getContentLength

public int getContentLength()
Returns the value of the "Content-Length" header field.

Returns:
The content length of the response, or -1 if the content length is not known.

getContentType

public String getContentType()
Returns the value of the "Content-Type" header field.

Returns:
The content type of the response, or null if not known.

getContentEncoding

public String getContentEncoding()
Returns the value of the "Content-Encoding" header field.

Returns:
The content encoding of the response, or null if not known.


Copyright © 2013 The Transaction Company. All Rights Reserved.