org.geotools.data.wfs.protocol.http
Interface HTTPProtocol

All Known Implementing Classes:
AbstractHttpProtocol, DefaultHTTPProtocol, SimpleHttpProtocol

public interface HTTPProtocol

A facade interface to interact with a plain HTTP server.

This interface provides a mean for plain HTTP conversation. That is, issueing HTTP requests both through GET and POST methods, handling gzip encoding/decoding if supported by the server, URL encoding for query string parameters, and handling HTTP authentication.

Since:
2.6
Author:
Gabriel Roldan (OpenGeo)
Module:

Nested Class Summary
static interface HTTPProtocol.POSTCallBack
           
 
Method Summary
 URL createUrl(URL baseUrl, Map<String,String> queryStringKvp)
          Creates an URL with baseUrl and a query string defined by the kvp key/value pair of parameters.
 int getTimeoutMillis()
          Returns the request timeout in milliseconds, defaults to -1 meaning no timeout
 HTTPResponse issueGet(URL baseUrl, Map<String,String> kvp)
          Issues an HTTP request over the baseUrl with a query string defined by the kvp key/value pair of parameters.
 HTTPResponse issuePost(URL targetUrl, HTTPProtocol.POSTCallBack callback)
           
 boolean isTryGzip()
          Returns whether gzip encoding is attempted when interacting with the HTTP server; default is false
 void setAuth(String username, String password)
          Sets the HTTP authentication realms (not required/used so far, but intended to be)
 void setTimeoutMillis(int milliseconds)
          Sets the request timeout in milliseconds.
 void setTryGzip(boolean tryGzip)
          Sets whether the server should be asked to return responses encoded in GZIP.
 

Method Detail

setTryGzip

void setTryGzip(boolean tryGzip)
Sets whether the server should be asked to return responses encoded in GZIP.

Parameters:
tryGzip - true to ask the server to encode responses in GZIP.

isTryGzip

boolean isTryGzip()
Returns whether gzip encoding is attempted when interacting with the HTTP server; default is false

Returns:
true if gzip is being attempted.

setAuth

void setAuth(String username,
             String password)
Sets the HTTP authentication realms (not required/used so far, but intended to be)

Parameters:
username -
password -

setTimeoutMillis

void setTimeoutMillis(int milliseconds)
Sets the request timeout in milliseconds.

Parameters:
milliseconds -

getTimeoutMillis

int getTimeoutMillis()
Returns the request timeout in milliseconds, defaults to -1 meaning no timeout

Returns:

issueGet

HTTPResponse issueGet(URL baseUrl,
                      Map<String,String> kvp)
                      throws IOException
Issues an HTTP request over the baseUrl with a query string defined by the kvp key/value pair of parameters.

If the base url query is not empty and already contains a parameter named as one of the parameters in kvp, the original parameter value in the baseUrl query is overriden by the one in the kvp map. For this purpose, the parameter name matching comparison is made case insensitively.

Parameters:
baseUrl - the URL where to fetch the contents from
kvp - the set of key/value pairs to create the actual URL query string, may be empty
Returns:
the server response of issuing the HTTP request through GET method
Throws:
IOException - if a communication error of some sort occurs
See Also:
createUrl(URL, Map)

issuePost

HTTPResponse issuePost(URL targetUrl,
                       HTTPProtocol.POSTCallBack callback)
                       throws IOException
Throws:
IOException

createUrl

URL createUrl(URL baseUrl,
              Map<String,String> queryStringKvp)
              throws MalformedURLException
Creates an URL with baseUrl and a query string defined by the kvp key/value pair of parameters.

If the base url query is not empty and already contains a parameter named as one of the parameters in kvp, the original parameter value in the baseUrl query is overriden by the one in the kvp map. For this purpose, the parameter name matching comparison is made case insensitively.

Parameters:
baseUrl - the original URL to create the new one from
kvp - the set of key/value pairs to create the actual URL query string, may be empty
Returns:
the new URL with baseUrl and the query string from queryStringKvp
Throws:
MalformedURLException - if the resulting URL is not valid


Copyright © 1996-2009 Geotools. All Rights Reserved.