org.geotools.data.ows
Class SimpleHttpClient

Object
  extended by SimpleHttpClient
All Implemented Interfaces:
HTTPClient

public class SimpleHttpClient
extends Object
implements HTTPClient

A simple HTTPClient that creates a new HTTP connection for each request.

Author:
groldan

Nested Class Summary
static class SimpleHttpClient.SimpleHTTPResponse
           
 
Constructor Summary
SimpleHttpClient()
           
 
Method Summary
 HTTPResponse get(URL url)
          Executes an HTTP GET request against the provided URL and returns the server response.
 int getConnectTimeout()
           
 String getPassword()
           
 int getReadTimeout()
           
 String getUser()
           
 boolean isTryGzip()
           
 HTTPResponse post(URL url, InputStream postContent, String postContentType)
          Executes an HTTP POST request against the provided URL, sending the contents of postContent as the POST method body and setting the Content-Type request header to postContentType if given, and returns the server response.
 void setConnectTimeout(int connectTimeout)
           
 void setPassword(String password)
           
 void setReadTimeout(int readTimeout)
           
 void setTryGzip(boolean tryGZIP)
           
 void setUser(String user)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleHttpClient

public SimpleHttpClient()
Method Detail

getUser

public String getUser()
Specified by:
getUser in interface HTTPClient
Returns:
the HTTP BASIC Authentication user name, or null if not set

setUser

public void setUser(String user)
Specified by:
setUser in interface HTTPClient
Parameters:
user - the HTTP BASIC Authentication user name

getPassword

public String getPassword()
Specified by:
getPassword in interface HTTPClient
Returns:
the HTTP BASIC Authentication password, or null if not set

setPassword

public void setPassword(String password)
Specified by:
setPassword in interface HTTPClient
Parameters:
password - the HTTP BASIC Authentication password

getConnectTimeout

public int getConnectTimeout()
Specified by:
getConnectTimeout in interface HTTPClient
Returns:
the tcp/ip connect timeout in seconds

setConnectTimeout

public void setConnectTimeout(int connectTimeout)
Specified by:
setConnectTimeout in interface HTTPClient
Parameters:
connectTimeout - tcp/ip connect timeout in seconds

getReadTimeout

public int getReadTimeout()
Specified by:
getReadTimeout in interface HTTPClient
Returns:
the socket read timeout in seconds

setReadTimeout

public void setReadTimeout(int readTimeout)
Specified by:
setReadTimeout in interface HTTPClient
Parameters:
readTimeout - socket read timeout in seconds

get

public HTTPResponse get(URL url)
                 throws IOException
Description copied from interface: HTTPClient
Executes an HTTP GET request against the provided URL and returns the server response.

If an HTTP authentication user and password is set, the appropriate authentication HTTP header will be sent with the request.

If a connection timeout is set, the http connection will be set to respect that timeout.

If a read timeout is set, the http connection will be set to respect it.

Specified by:
get in interface HTTPClient
Parameters:
url - the URL to retrieve
Returns:
an HTTPResponse encapsulating the response to the HTTP GET request
Throws:
IOException
See Also:
HTTPClient.get(java.net.URL)

post

public HTTPResponse post(URL url,
                         InputStream postContent,
                         String postContentType)
                  throws IOException
Description copied from interface: HTTPClient
Executes an HTTP POST request against the provided URL, sending the contents of postContent as the POST method body and setting the Content-Type request header to postContentType if given, and returns the server response.

If an HTTP authentication user and password is set, the appropriate authentication HTTP header will be sent with the request.

If a connection timeout is set, the http connection will be set to respect that timeout.

If a read timeout is set, the http connection will be set to respect it.

Specified by:
post in interface HTTPClient
Parameters:
url - the URL against which to execute the POST request
postContent - an input stream with the contents of the POST body
postContentType - the MIME type of the contents sent as the request POST body, can be null
Returns:
the HTTPResponse encapsulating the response to the HTTP POST request
Throws:
IOException
See Also:
HTTPClient.post(java.net.URL, java.io.InputStream, java.lang.String)

setTryGzip

public void setTryGzip(boolean tryGZIP)
Specified by:
setTryGzip in interface HTTPClient
Parameters:
tryGZIP -
See Also:
HTTPClient.setTryGzip(boolean)

isTryGzip

public boolean isTryGzip()
Specified by:
isTryGzip in interface HTTPClient
Returns:
See Also:
HTTPClient.isTryGzip()


Copyright © 1996-2014 Geotools. All Rights Reserved.