Esri Geoportal Server
1.0

com.esri.gpt.framework.http
Class HttpClientRequest

java.lang.Object
  extended by com.esri.gpt.framework.http.HttpClientRequest

public class HttpClientRequest
extends Object

Provides an interface for the execution of outbound HTTP requests.

This class delegates underlying HTTP related functonality the the Apache HttpClient.

If a forward proxy is in place, the following system properties must be configured at the Java web server level (e.g. Tomcat - catalina.properties)

If the forward proxy requires credentials, the following system properties are considered: The gpt.xml file can be used to set the proxyUser/proxyPassword properties based upon an encrypted password:
<gtpConfig>
<forwardProxyAuth
username=""
password=""
encrypted="true"/>
</gtpConfig>

The above system properties are also used by the Apache Axis module for SOAP based comminication.


Nested Class Summary
static class HttpClientRequest.MethodName
          The enumeration of upported HTTP method names.
 
Constructor Summary
HttpClientRequest()
          Default constructor.
 
Method Summary
 void execute()
          Executes the HTTP request.
 int getConnectionTimeOutMs()
          Gets the connection time out in milliseconds.
 ContentHandler getContentHandler()
          Gets the handler for the content of the HTTP response body.
 ContentProvider getContentProvider()
          Gets the provider for the content of the HTTP request body.
 CredentialProvider getCredentialProvider()
          Gets the provider for HTTP authorization credentials.
 StringBuffer getExecutionLog()
          Gets a buffer representing the loggable content of an executed HTTP request.
 HttpClientRequest.MethodName getMethodName()
          Gets the HTTP method name.
 ResponseInfo getResponseInfo()
          Gets information associated with an HTTP response.
 int getResponseTimeOutMs()
          Gets the response time out in milliseconds
 int getRetries()
          Gets the retries.
 String getUrl()
          Gets the URL for the request.
static HttpClientRequest newRequest()
          Instantiates a new HTTP client request.
static HttpClientRequest newRequest(HttpClientRequest.MethodName name, String url)
          Instantiates a new HTTP client request.
 String readResponseAsCharacters()
          Exceutes the HPPR request and returns the response as a string.
 void setConnectionTimeMs(int connectionTimeOut)
          Sets the connection time out in milliseconds.
 void setContentHandler(ContentHandler handler)
          Sets the handler for the content of the HTTP response body.
 void setContentProvider(ContentProvider provider)
          Sets the provider for the content of the HTTP request body.
 void setCredentialProvider(CredentialProvider provider)
          Sets the provider for HTTP authorization credentials.
 void setMethodName(HttpClientRequest.MethodName name)
          Sets the HTTP method name.
 void setRequestHeader(String name, String value)
          Sets an HTTP request header value.
protected  void setResponseInfo(ResponseInfo info)
          Sets information associated with an HTTP response.
 void setResponseTimeOutMs(int responseTimeOut)
          Sets the response time out in milliseconds.
 void setRetries(int retries)
          Sets the retries.
 void setUrl(String url)
          Sets the URL for the request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpClientRequest

public HttpClientRequest()
Default constructor.

Method Detail

getConnectionTimeOutMs

public int getConnectionTimeOutMs()
Gets the connection time out in milliseconds.

Returns:
the connection time out (always >= 0)

setConnectionTimeMs

public void setConnectionTimeMs(int connectionTimeOut)
Sets the connection time out in milliseconds.

Parameters:
connectionTimeOut - the new connection time out

getResponseTimeOutMs

public int getResponseTimeOutMs()
Gets the response time out in milliseconds

Returns:
the response time out (always >= 0)

setResponseTimeOutMs

public void setResponseTimeOutMs(int responseTimeOut)
Sets the response time out in milliseconds.

Parameters:
responseTimeOut - the new response time out

getCredentialProvider

public CredentialProvider getCredentialProvider()
Gets the provider for HTTP authorization credentials.

Returns:
the credential provider

setCredentialProvider

public void setCredentialProvider(CredentialProvider provider)
Sets the provider for HTTP authorization credentials.

Parameters:
provider - the credential provider

getContentHandler

public ContentHandler getContentHandler()
Gets the handler for the content of the HTTP response body.

Returns:
the response content handler

setContentHandler

public void setContentHandler(ContentHandler handler)
Sets the handler for the content of the HTTP response body.

Parameters:
handler - the response content handler

getContentProvider

public ContentProvider getContentProvider()
Gets the provider for the content of the HTTP request body.

Returns:
the request content provider

setContentProvider

public void setContentProvider(ContentProvider provider)
Sets the provider for the content of the HTTP request body.

Parameters:
provider - the request content provider

getExecutionLog

public StringBuffer getExecutionLog()
Gets a buffer representing the loggable content of an executed HTTP request.

Returns:
the execution log buffer

getMethodName

public HttpClientRequest.MethodName getMethodName()
Gets the HTTP method name.

Returns:
the method name

setMethodName

public void setMethodName(HttpClientRequest.MethodName name)
Sets the HTTP method name.

Parameters:
name - the method name

setRequestHeader

public void setRequestHeader(String name,
                             String value)
Sets an HTTP request header value.

Parameters:
name - the header paramater name
value - the header paramater value

getResponseInfo

public ResponseInfo getResponseInfo()
Gets information associated with an HTTP response.

Returns:
the HTTP response information

setResponseInfo

protected void setResponseInfo(ResponseInfo info)
Sets information associated with an HTTP response.

Parameters:
info - the HTTP response information

getUrl

public String getUrl()
Gets the URL for the request.

Returns:
the request URL

setUrl

public void setUrl(String url)
Sets the URL for the request.

Parameters:
url - the request URL

getRetries

public int getRetries()
Gets the retries.

Returns:
the retries

setRetries

public void setRetries(int retries)
Sets the retries.

Parameters:
retries - the new retries

execute

public void execute()
             throws IOException
Executes the HTTP request.

Throws:
IOException - if an Exception occurs

newRequest

public static HttpClientRequest newRequest()
Instantiates a new HTTP client request.

Returns:
the HTTP client request

newRequest

public static HttpClientRequest newRequest(HttpClientRequest.MethodName name,
                                           String url)
Instantiates a new HTTP client request.

Parameters:
name - the HTTP method name
url - the target URL
Returns:
the HTTP client request

readResponseAsCharacters

public String readResponseAsCharacters()
                                throws IOException
Exceutes the HPPR request and returns the response as a string.

Returns:
the HTTP response
Throws:
IOException - if an i/o exception occurs

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.