org.springframework.http.client
Class SimpleClientHttpRequestFactory

java.lang.Object
  extended by org.springframework.http.client.SimpleClientHttpRequestFactory
All Implemented Interfaces:
ClientHttpRequestFactory

public class SimpleClientHttpRequestFactory
extends Object
implements ClientHttpRequestFactory

ClientHttpRequestFactory implementation that uses standard J2SE facilities.

Since:
3.0
Author:
Arjen Poutsma
See Also:
HttpURLConnection, CommonsClientHttpRequestFactory

Constructor Summary
SimpleClientHttpRequestFactory()
           
 
Method Summary
 ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod)
          Create a new ClientHttpRequest for the specified URI and HTTP method.
protected  void prepareConnection(HttpURLConnection connection, String httpMethod)
          Template method for preparing the given HttpURLConnection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleClientHttpRequestFactory

public SimpleClientHttpRequestFactory()
Method Detail

createRequest

public ClientHttpRequest createRequest(URI uri,
                                       HttpMethod httpMethod)
                                throws IOException
Description copied from interface: ClientHttpRequestFactory
Create a new ClientHttpRequest for the specified URI and HTTP method.

The returned request can be written to, and then executed by calling ClientHttpRequest.execute().

Specified by:
createRequest in interface ClientHttpRequestFactory
Parameters:
uri - the URI to create a request for
httpMethod - the HTTP method to execute
Returns:
the created request
Throws:
IOException - in case of I/O errors

prepareConnection

protected void prepareConnection(HttpURLConnection connection,
                                 String httpMethod)
                          throws IOException
Template method for preparing the given HttpURLConnection.

The default implementation prepares the connection for input and output, and sets the HTTP method.

Parameters:
connection - the connection to prepare
httpMethod - the HTTP request method (GET, POST, etc.)
Throws:
IOException - in case of I/O errors