de.enough.polish.browser.protocols
Class HttpProtocolHandler

java.lang.Object
  extended by de.enough.polish.browser.ProtocolHandler
      extended by de.enough.polish.browser.protocols.HttpProtocolHandler

public class HttpProtocolHandler
extends ProtocolHandler

Protocol handler class to handle HTTP. The sent user agent is normally the string defined in the microedition.platform system property. You can overwrite this value by defining the polish.Browser.UserAgent variable in your build.xml.


Field Summary
 
Fields inherited from class de.enough.polish.browser.ProtocolHandler
bytebuf, protocolName
 
Constructor Summary
HttpProtocolHandler()
          Creates a new HttpProtocolHandler object with "http" as it's protocol.
HttpProtocolHandler(HashMap requestProperties)
          Creates a new HttpProtocolHandler object with "http" as it's protocol.
HttpProtocolHandler(String protocolName)
          Creates a new HttpProtocolHandler object.
HttpProtocolHandler(String protocolName, HashMap requestProperties)
          Creates a new HttpProtocolHandler object.
 
Method Summary
 StreamConnection getConnection(String url)
          Creates a StreamConnection for the given url.
static String getUserAgent()
          Returns the user agent string
static void setUserAgent(String userAgent)
          Sets the USER_AGENT string used for the request header
 
Methods inherited from class de.enough.polish.browser.ProtocolHandler
getProtocolName, readByteArrayFromStream, stripProtocol
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpProtocolHandler

public HttpProtocolHandler()
Creates a new HttpProtocolHandler object with "http" as it's protocol.


HttpProtocolHandler

public HttpProtocolHandler(HashMap requestProperties)
Creates a new HttpProtocolHandler object with "http" as it's protocol.

Parameters:
requestProperties - the request properties to use for each request

HttpProtocolHandler

public HttpProtocolHandler(String protocolName)
Creates a new HttpProtocolHandler object.

Parameters:
protocolName - the protocolname (usually "http" or "https")

HttpProtocolHandler

public HttpProtocolHandler(String protocolName,
                           HashMap requestProperties)
Creates a new HttpProtocolHandler object.

Parameters:
protocolName - the protocolname (usually "http" or "https")
requestProperties - the request properties to use for each request
Method Detail

setUserAgent

public static void setUserAgent(String userAgent)
Sets the USER_AGENT string used for the request header

Parameters:
userAgent - the USER_AGENT string to set

getUserAgent

public static String getUserAgent()
Returns the user agent string

Returns:
the user agent string

getConnection

public StreamConnection getConnection(String url)
                               throws IOException
Description copied from class: ProtocolHandler
Creates a StreamConnection for the given url.

Specified by:
getConnection in class ProtocolHandler
Parameters:
url - the url
Returns:
the stream conenction for the given url
Throws:
IOException - if an error occurs