com.funambol.syncml.spds
Class HttpTransportAgent

java.lang.Object
  extended by com.funambol.syncml.spds.HttpTransportAgent
All Implemented Interfaces:
TransportAgent

public final class HttpTransportAgent
extends java.lang.Object
implements TransportAgent

Represents a HTTP client implementation


Constructor Summary
HttpTransportAgent(java.lang.String requestURL, boolean compress, boolean forceCookies)
          Create a new HttpTransportAgent.
HttpTransportAgent(java.lang.String requestURL, java.lang.String userAgent, boolean compress, boolean forceCookies)
          Create a new HttpTransportAgent using the default charset.
HttpTransportAgent(java.lang.String requestURL, java.lang.String userAgent, java.lang.String charset, boolean compress, boolean forceCookies)
          Initialize a new HttpTransportAgent with a URL and a charset to use.
 
Method Summary
 void enableCompression(boolean enable)
          Enable the http "gzip" compression parameter usage
 java.lang.String getResponseDate()
          Get the last response date
 byte[] sendMessage(byte[] request)
          Send the http request and read the response
 java.lang.String sendMessage(java.lang.String request)
          Send a message using the default (UTF-8) charset.
 java.lang.String sendMessage(java.lang.String request, java.lang.String charset)
          Send the http request specifying the required encoding charset for the http headers. and read the response
 void setRequestURL(java.lang.String requestURL)
          Set the request's url
 void setRetryOnWrite(int retryOnWrite)
          Set the number of http writing attempts
 void setThreshold(int threshold)
          Set the http "Size-Threshold" header parameter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpTransportAgent

public HttpTransportAgent(java.lang.String requestURL,
                          boolean compress,
                          boolean forceCookies)
Create a new HttpTransportAgent.

Parameters:
requestURL - is the url where to send the request; must not be null
compress - if true the http compression is enabled, disabled otherwise
forceCookies -

HttpTransportAgent

public HttpTransportAgent(java.lang.String requestURL,
                          java.lang.String userAgent,
                          boolean compress,
                          boolean forceCookies)
Create a new HttpTransportAgent using the default charset.

Parameters:
requestURL - is the url where to send the request; must not be null
userAgent - the user agent parameter to be filled into the http headers
compress - if true the http compression is enabled, disabled otherwise
forceCookies - if true sets http headers to force the use of cookies instead of Url Rewriting to manage the current http session.

HttpTransportAgent

public HttpTransportAgent(java.lang.String requestURL,
                          java.lang.String userAgent,
                          java.lang.String charset,
                          boolean compress,
                          boolean forceCookies)
Initialize a new HttpTransportAgent with a URL and a charset to use.

Parameters:
requestURL - must be non-null
userAgent - a string to be used as userAgent.
charset - a valid charset, the device charset is used by default.
Method Detail

sendMessage

public java.lang.String sendMessage(java.lang.String request)
                             throws SyncException
Send a message using the default (UTF-8) charset.

Specified by:
sendMessage in interface TransportAgent
Parameters:
requestURL - must be non-null
Returns:
String formatted http response
Throws:
SyncException - when the connection cannot be established with the server because the implementation tries to access a not existent url or when there are network coverage problems

sendMessage

public java.lang.String sendMessage(java.lang.String request,
                                    java.lang.String charset)
                             throws SyncException
Send the http request specifying the required encoding charset for the http headers. and read the response

Specified by:
sendMessage in interface TransportAgent
Parameters:
request - the http request body
charset - the charset to be included into the http headers
Returns:
String formatted http response
Throws:
SyncException - when the connection cannot be established with the server because the implementation tries to access a not existent url or when there are network coverage problems

sendMessage

public byte[] sendMessage(byte[] request)
                   throws SyncException
Send the http request and read the response

Parameters:
request - the http request body
Returns:
byte[] raw http response
Throws:
SyncException - when the connection cannot be established with the server because the implementation tries to access a not existent url or when there are network coverage problems

enableCompression

public void enableCompression(boolean enable)
Enable the http "gzip" compression parameter usage

Parameters:
enable - enables "gzip" http header parameter to be written if true

setThreshold

public void setThreshold(int threshold)
Set the http "Size-Threshold" header parameter

Parameters:
threshold - is the "Size-Threshold" value to be added to http headers

setRequestURL

public void setRequestURL(java.lang.String requestURL)
Set the request's url

Parameters:
requestURL - the request's destination url

getResponseDate

public java.lang.String getResponseDate()
Get the last response date

Returns:
the last response date (String format), if available, null otherwise

setRetryOnWrite

public void setRetryOnWrite(int retryOnWrite)
Set the number of http writing attempts

Specified by:
setRetryOnWrite in interface TransportAgent
Parameters:
retryOnWrite - the number of attempts to write http requests


Copyright © 2006 Funambol.