gov.llnl.babel.url
Class CookieConnection

java.lang.Object
  extended by gov.llnl.babel.url.CookieConnection

public class CookieConnection
extends java.lang.Object

Class CookieConnection caches cookies for a HTTP or HTTPS connection. It provides methods to post and get data and maintains cookie state.


Constructor Summary
CookieConnection()
          Create a new cookie connection and initialize the cookie state to be empty.
 
Method Summary
 java.io.InputStream getFromURL(java.lang.String url_string)
          Open a GET connection to the specified URL and return the associated input stream, which must be closed by the callee.
 void postToURL(java.lang.String url_string, java.lang.String content_type, java.io.InputStream content)
          Open a POST connection to the specified URL and submit the specified input stream with the associated content type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CookieConnection

public CookieConnection()
Create a new cookie connection and initialize the cookie state to be empty. Cookies will be added during gets and posts to the connection.

Method Detail

getFromURL

public java.io.InputStream getFromURL(java.lang.String url_string)
                               throws HttpException,
                                      java.io.IOException
Open a GET connection to the specified URL and return the associated input stream, which must be closed by the callee. If this is an HTTP or HTTPS URL, then cookies are cached across multiple connections. An IOException is thrown if there is an I/O error or if the status response from the HTTP server indicates an error.

Throws:
HttpException
java.io.IOException

postToURL

public void postToURL(java.lang.String url_string,
                      java.lang.String content_type,
                      java.io.InputStream content)
               throws HttpException,
                      java.io.IOException
Open a POST connection to the specified URL and submit the specified input stream with the associated content type. If this is an HTTP or HTTPS URL, then cookies are cached across multiple connections. An IOException is thrown if there is an I/O error or if the status response from the HTTP server indicates an error. The content stream is closed after its data is transferred to the server.

Throws:
HttpException
java.io.IOException