Secure iNet Factory

com.jscape.inet.http
Class HttpSession

java.lang.Object
  extended by com.jscape.inet.http.HttpSession

public class HttpSession
extends java.lang.Object

Implements the basic functionality of an HTTP client automatically managing all session data in memory.

Example:

 HttpSession session = new HttpSession();
 HttpResponse response1 = session.getResponse("http://www.mydomain.com/page1");
 HttpResponse response2 = session.getResponse("http://www.mydomain.com/page2");
 HttpRequest page3 = new HttpRequest("http://www.mydomain.com/page3");
 page3.addParameter("username","jsmith");
 page3.addParameter("password","secret"); *
 HttpResponse response3 = session.getResponse(page3);
 


Constructor Summary
HttpSession()
          Creates a new HttpSession instance.
HttpSession(Http http)
          Creates a new HttpSession instance.
 
Method Summary
 java.util.Vector getCookiesForHost(java.lang.String host)
          Gets all cookies for the specified hostname
 java.io.PrintStream getDebugStream()
          Gets debug stream used for debug messages.
 HttpResponse getResponse(HttpRequest request)
          Gets response from HTTP server.
 HttpResponse getResponse(java.lang.String url)
          Gets response from HTTP server.
 HttpResponse getResponse(java.lang.String url, java.lang.String method)
          Gets response from HTTP server.
 boolean isAllowCookies()
          Checks if cookies are allowed to be stored in memory.
 boolean isDebug()
          Checks if debugging is enabled.
 void setAllowCookies(boolean allowCookies)
          Sets whether cookies are allowed to be stored in memory.
 void setDebug(boolean debug)
          Enables or disables debugging.
 void setDebugStream(java.io.PrintStream debugStream)
          Sets debug stream to be used for debug messages.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpSession

public HttpSession()
Creates a new HttpSession instance.


HttpSession

public HttpSession(Http http)
Creates a new HttpSession instance.

Parameters:
http - an Http instance.
See Also:
Http
Method Detail

getResponse

public HttpResponse getResponse(java.lang.String url,
                                java.lang.String method)
                         throws HttpException
Gets response from HTTP server.

Parameters:
url - the web address to retrieve
method - the method, valid values are GET and POST
Returns:
an HttpResponse
Throws:
HttpException - if an I/O or HTTP related error occurs

getResponse

public HttpResponse getResponse(java.lang.String url)
                         throws HttpException
Gets response from HTTP server.

Parameters:
url - the web address to retrieve
Returns:
an HttpResponse
Throws:
HttpException - if an I/O or HTTP related error occurs

getResponse

public HttpResponse getResponse(HttpRequest request)
                         throws HttpException
Gets response from HTTP server.

Parameters:
request - an HttpRequest
Returns:
an HttpResponse
Throws:
HttpException - if an I/O or HTTP related error occurs

getCookiesForHost

public java.util.Vector getCookiesForHost(java.lang.String host)
Gets all cookies for the specified hostname

Parameters:
host - the hostname to find cookies for
Returns:
a Vector of cookies

isAllowCookies

public boolean isAllowCookies()
Checks if cookies are allowed to be stored in memory. Default is true.

Returns:
true if cookies are allowed, false otherwise

setAllowCookies

public void setAllowCookies(boolean allowCookies)
Sets whether cookies are allowed to be stored in memory.

Parameters:
allowCookies - true if cookies are allowed, false otherwise

setDebug

public void setDebug(boolean debug)
Enables or disables debugging. Default is true.

Parameters:
debug - true if enabled, false otherwise.

isDebug

public boolean isDebug()
Checks if debugging is enabled. Default is true.

Returns:
true if enabled, false otherwise

setDebugStream

public void setDebugStream(java.io.PrintStream debugStream)
Sets debug stream to be used for debug messages. Default is System.out

Parameters:
debugStream - a PrintStream
See Also:
PrintStream

getDebugStream

public java.io.PrintStream getDebugStream()
Gets debug stream used for debug messages. Default is System.out

Returns:
a PrintStream
See Also:
PrintStream

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved