Restlet Framework 2.2.2
Java Standard Edition

org.restlet.engine.connector
Class HttpUrlConnectionCall

java.lang.Object
  extended by org.restlet.engine.adapter.Call
      extended by org.restlet.engine.adapter.ClientCall
          extended by org.restlet.engine.connector.HttpUrlConnectionCall

public class HttpUrlConnectionCall
extends ClientCall

HTTP client connector call based on JDK's java.net.HttpURLConnection class. On the GAE edition, it also supports the SDC protocol by setting automatically the special "use_intranet" header.

Author:
Jerome Louvel

Constructor Summary
HttpUrlConnectionCall(HttpClientHelper helper, String method, String requestUri, boolean hasEntity)
          Constructor.
 
Method Summary
 HttpURLConnection getConnection()
          Returns the connection.
 HttpClientHelper getHelper()
          Returns the HTTP client helper.
 String getReasonPhrase()
          Returns the response reason phrase.
protected  Representation getRepresentation(InputStream stream)
          Returns the representation wrapping the given stream.
 WritableByteChannel getRequestEntityChannel()
          Returns the request entity channel if it exists.
 OutputStream getRequestEntityStream()
          Returns the request entity stream if it exists.
 OutputStream getRequestHeadStream()
          Returns the request head stream if it exists.
 OutputStream getRequestStream()
          Returns the request entity stream if it exists.
 ReadableByteChannel getResponseEntityChannel(long size)
          Returns the response channel if it exists.
 InputStream getResponseEntityStream(long size)
          Returns the response entity stream if it exists.
 Series<Header> getResponseHeaders()
          Returns the modifiable list of response headers.
 String getServerAddress()
          Returns the response address.
Corresponds to the IP address of the responding server.
 int getStatusCode()
          Returns the response status code.
 Status sendRequest(Request request)
          Sends the request to the client.
 void sendRequest(Request request, Response response, Uniform callback)
          Sends the request to the client.
 
Methods inherited from class org.restlet.engine.adapter.ClientCall
getContentLength, getLocalAddress, getResponseEntity, isClientKeepAlive, isServerKeepAlive, shouldRequestBeChunked
 
Methods inherited from class org.restlet.engine.adapter.Call
getClientAddress, getClientPort, getHostDomain, getHostPort, getLogger, getMethod, getProtocol, getRepresentation, getRequestHeaders, getRequestUri, getServerPort, getUserPrincipal, getVersion, isBroken, isConfidential, isConnectionBroken, isKeepAlive, isRequestChunked, isResponseChunked, setClientAddress, setClientPort, setConfidential, setHostDomain, setHostPort, setMethod, setProtocol, setReasonPhrase, setRequestUri, setServerAddress, setServerPort, setStatusCode, setUserPrincipal, setVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpUrlConnectionCall

public HttpUrlConnectionCall(HttpClientHelper helper,
                             String method,
                             String requestUri,
                             boolean hasEntity)
                      throws IOException
Constructor.

Parameters:
helper - The parent HTTP client helper.
method - The method name.
requestUri - The request URI.
hasEntity - Indicates if the call will have an entity to send to the server.
Throws:
IOException
Method Detail

getConnection

public HttpURLConnection getConnection()
Returns the connection.

Returns:
The connection.

getHelper

public HttpClientHelper getHelper()
Returns the HTTP client helper.

Overrides:
getHelper in class ClientCall
Returns:
The HTTP client helper.

getReasonPhrase

public String getReasonPhrase()
Returns the response reason phrase.

Overrides:
getReasonPhrase in class Call
Returns:
The response reason phrase.

getRepresentation

protected Representation getRepresentation(InputStream stream)
Description copied from class: Call
Returns the representation wrapping the given stream.

Overrides:
getRepresentation in class Call
Parameters:
stream - The response input stream.
Returns:
The wrapping representation.

getRequestEntityChannel

public WritableByteChannel getRequestEntityChannel()
Description copied from class: ClientCall
Returns the request entity channel if it exists.

Specified by:
getRequestEntityChannel in class ClientCall
Returns:
The request entity channel if it exists.

getRequestEntityStream

public OutputStream getRequestEntityStream()
Description copied from class: ClientCall
Returns the request entity stream if it exists.

Specified by:
getRequestEntityStream in class ClientCall
Returns:
The request entity stream if it exists.

getRequestHeadStream

public OutputStream getRequestHeadStream()
Description copied from class: ClientCall
Returns the request head stream if it exists.

Specified by:
getRequestHeadStream in class ClientCall
Returns:
The request head stream if it exists.

getRequestStream

public OutputStream getRequestStream()
Returns the request entity stream if it exists.

Returns:
The request entity stream if it exists.

getResponseEntityChannel

public ReadableByteChannel getResponseEntityChannel(long size)
Description copied from class: ClientCall
Returns the response channel if it exists.

Specified by:
getResponseEntityChannel in class ClientCall
Parameters:
size - The expected entity size or -1 if unknown.
Returns:
The response channel if it exists.

getResponseEntityStream

public InputStream getResponseEntityStream(long size)
Description copied from class: ClientCall
Returns the response entity stream if it exists.

Specified by:
getResponseEntityStream in class ClientCall
Parameters:
size - The expected entity size or -1 if unknown.
Returns:
The response entity stream if it exists.

getResponseHeaders

public Series<Header> getResponseHeaders()
Returns the modifiable list of response headers.

Overrides:
getResponseHeaders in class Call
Returns:
The modifiable list of response headers.

getServerAddress

public String getServerAddress()
Returns the response address.
Corresponds to the IP address of the responding server.

Overrides:
getServerAddress in class Call
Returns:
The response address.

getStatusCode

public int getStatusCode()
                  throws IOException
Returns the response status code.

Overrides:
getStatusCode in class Call
Returns:
The response status code.
Throws:
IOException
IOException

sendRequest

public Status sendRequest(Request request)
Sends the request to the client. Commits the request line, headers and optional entity and send them over the network.

Overrides:
sendRequest in class ClientCall
Parameters:
request - The high-level request.
Returns:
The result status.

sendRequest

public void sendRequest(Request request,
                        Response response,
                        Uniform callback)
                 throws Exception
Description copied from class: ClientCall
Sends the request to the client. Commits the request line, headers and optional entity and send them over the network.

Overrides:
sendRequest in class ClientCall
Parameters:
request - The high-level request.
response - The high-level response.
callback - The callback invoked upon request completion.
Throws:
Exception

Restlet Framework 2.2.2
Java Standard Edition

Copyright © 2005-2014 Restlet.