autohit.transport
Class HTTPTransport

java.lang.Object
  |
  +--autohit.transport.HTTPTransport

public class HTTPTransport
extends java.lang.Object
implements Transport, HTTPClient.CookiePolicyHandler

A HTTP transport. It uses the HTTPClient library. for http implementation specifics, see the library documentation.

I'm thinking that HTTPClient will have to get replaced. It will be slow. It works for multi-client simulation, but it isn't designed for it. I'm worried that Objects and cookies will ghost and build up.


Constructor Summary
HTTPTransport()
          Default constructor.
 
Method Summary
 boolean acceptCookie(HTTPClient.Cookie cookie, HTTPClient.RoRequest req, HTTPClient.RoResponse resp)
          Just don't use these...
 void connect(java.lang.String address)
          Prepare to connect to a web server.
 void disconnect()
          Disconnect transport.
 void environment(java.lang.String name, java.lang.String value)
          Set an environment variable for this transport.
 Response push(Query q)
          Push a query and wait for a response.
 boolean sendCookie(HTTPClient.Cookie cookie, HTTPClient.RoRequest req)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPTransport

public HTTPTransport()
Default constructor.
Method Detail

connect

public void connect(java.lang.String address)
             throws TransportException
Prepare to connect to a web server. If this method is subsiquently called BEFORE the connection is disconnect()'ed, it will throw a TransportException. The port can be specified in the address--such as "my.domain.com:8080"
Specified by:
connect in interface Transport
Parameters:
address - Address specification. This should only be the DOMAIN portion of a URL.
Throws:
TransportException -  

push

public Response push(Query q)
              throws TransportException
Push a query and wait for a response.

  The Query should be formed as the following:
      Query.headers = any non-default headers.  Be careful that they they
                      don't break how HTTPClient works.
      Query.qs      = The URI query string including URL encoded variables.
                      It should include the "/" after the domain in URI--such
                      as "/cgi-bin/goats.pl" rather than "cgi-bin/goats.pl"
      Query.body    = Any body elements.  If this is null, then the http GET method
                      will be used.  Otherwise, http POST is used and this body will
                      be the form data.
  

WARNING! For now, headers are not given in the Response. Reponse.header will be null.

If it is not connected or there is an underlying transport error, it will throw a TransportException.

Specified by:
push in interface Transport
Parameters:
q - A queury specification.
Returns:
A response object.
Throws:
TransportException -  
See Also:
Query, Response

environment

public void environment(java.lang.String name,
                        java.lang.String value)
Set an environment variable for this transport.

  The following as defined for this transport.  (Defaults shown in paren.)

      - Accept cookies?   "cookies" == "true" or "false" (true)
      - Allow redirects?  "redir" == "true" or "false" (true)
                          WARNING!  For now, redirects will ALWAYS be allowed.
                          I'll have to hack the HTTPClient to change this....
  

Names and boolean values are NOT case sensitive.

Specified by:
environment in interface Transport
Parameters:
name - variable name.
value - variable value.

disconnect

public void disconnect()
Disconnect transport.

If it isn't currently connected, nothing bad will happen.

Specified by:
disconnect in interface Transport

acceptCookie

public boolean acceptCookie(HTTPClient.Cookie cookie,
                            HTTPClient.RoRequest req,
                            HTTPClient.RoResponse resp)
Just don't use these... We will use the environemnt var to decide whether to allow cookies....
Specified by:
acceptCookie in interface HTTPClient.CookiePolicyHandler

sendCookie

public boolean sendCookie(HTTPClient.Cookie cookie,
                          HTTPClient.RoRequest req)
Specified by:
sendCookie in interface HTTPClient.CookiePolicyHandler