gov.llnl.babel.url

Class 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

InputStream
getFromURL(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(String url_string, String content_type, InputStream content)
Open a POST connection to the specified URL and submit the specified input stream with the associated content type.

Constructor Details

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 Details

getFromURL

public InputStream getFromURL(String url_string)
            throws HttpException,
                   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.

postToURL

public void postToURL(String url_string,
                      String content_type,
                      InputStream content)
            throws HttpException,
                   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.