02/28/2005
 

Package com.vignette.portal.rsm.http

HTTP(S) implementation of the RSM API.

See:
          Package Summary

Interface Summary
RequestContentStream Interface for writing an output stream that consists of a long string, or of binary or other non-string data.
 

Class Summary
Cookie Represents a Cookie set by a remote HTTP server.
CookieStore Maintains cookie state for an HTTP session and provides utility methods for HTTP cookie-related operations.
HttpRemoteRequest Represents a request to be made to the remote server.
HttpRemoteResponse Represents a response from a remote HTTP server.
HttpRemoteSession Models an HTTP session on a remote server or cluster of servers.
MultipartRequestContentStream MultipartRequestContentStream Sends a multipart-MIME POST request to a remote server.
 

Package com.vignette.portal.rsm.http Description

HTTP(S) implementation of the RSM API.

Usage

Client code will initiate use of the API by creating a session. The RemoteSessionFactory object contains a factory method (createRemoteSession()) that creates a session for a given protocol. If the protocol is unknown or unsupported, an UnsupportedProtocolException is thrown.


try {
	RemoteSession session = RemoteSessionFactory.createRemoteSession("http");
} catch (UnsupportedProtocolException e) {...}

This creates a representation in your code of a session on a remote server. The session object can then be cast to the appropriate protocol-specific session implementation to set specific session information:

if (session instanceof HttpRemoteSession) {
	HttpRemoteSession http_session = (HttpRemoteSession)session;

	http_session.setUserAgent(HttpRemoteRequest.USER_AGENT_NETSCAPE_6_2_3);
	http_session.setRequestMethod(HttpRemoteRequest.HTTP_METHOD_GET);
}

The session is then used to create requests to a remote server:

URL url = new URL("http://server/");
HttpRemoteRequest http_request = (HttpRemoteRequest)http_session.createRequest(url);

The request state can then be altered:

http_request.setUserAgent(HttpRemoteRequest.USER_AGENT_NETSCAPE_6_2_3);
http_request.setRequestMethod(HttpRemoteRequest.HTTP_METHOD_GET);
http_request.addHeaderValue("myheader", "myheadervalue");

Once the request's state is satisfactory, client code instructs the request to retrieve a response:

try {
	HttpRemoteResponse = (HttpRemoteResponse)http_request.performRequest(5000);
} catch (IOException e) {...}
catch (TimeoutException e) {...}
catch (InterruptedException e) {...}

The HttpRemoteRequest object opens a connection to the server and sends the request. If a response is given, the HttpRemoteResponse object is constructed and returned. Please note that no body content is retrieved at this time, as client code might need to inspect the response state (status code, etc) before deciding on whether to retrieve content:

try {
	HttpRemoteResponse = (HttpRemoteResponse)http_request.performRequest(5000);

	if (http_response == null || http_response.getStatusCode() != 200 || http_response.getContentLength() <= 0) {
		return;
	}

	String my_response_header = http_request.getHeaderValue("myresponseheader");
} catch (IOException e) {...}
catch (TimeoutException e) {...}
catch (InterruptedException e) {...}

Once client code has determined that content should be retrieved, it can do so in three ways:

Since:
7.0
See Also:
com.vignette.portal.rsm

02/28/2005
 

Copyright and Trademark Notices