org.deegree.framework.util
Class HttpUtils
java.lang.Object
org.deegree.framework.util.HttpUtils
public class HttpUtils
- extends Object
utility class for performing HTTP requests
- Author:
- Andreas Poth, last edited by: $Author: apoth $
|
Method Summary |
static String |
addAuthenticationForKVP(String url,
String user,
String password,
String sessionID)
|
static XMLFragment |
addAuthenticationForXML(XMLFragment xml,
String user,
String password,
String sessionID)
|
static String |
normalizeURL(String url)
|
static String |
normalizeURL(URL url)
|
static org.apache.commons.httpclient.HttpMethod |
performHttpGet(String url,
String request,
int timeout,
String user,
String password,
Map<String,String> header)
|
static org.apache.commons.httpclient.HttpMethod |
performHttpPost(String url,
InputStream content,
int timeout,
String user,
String password,
String contentType,
String encoding,
Map<String,String> header)
|
static org.apache.commons.httpclient.HttpMethod |
performHttpPost(String url,
String content,
int timeout,
String user,
String password,
String contentType,
String encoding,
Map<String,String> header)
|
static org.apache.commons.httpclient.HttpMethod |
performHttpPost(String url,
XMLFragment content,
int timeout,
String user,
String password,
Map<String,String> header)
|
static int |
validateURL(String url)
validates passed URL. |
static int |
validateURL(String url,
String user,
String password)
validates passed URL. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HttpUtils
public HttpUtils()
validateURL
public static int validateURL(String url)
throws IOException
- validates passed URL. If it is not a valid URL or a client can not connect to it an exception will be thrown
- Parameters:
url -
- Throws:
IOException
validateURL
public static int validateURL(String url,
String user,
String password)
throws IOException
- validates passed URL. If it is not a valid URL or a client can not connect to it an exception will be thrown
- Parameters:
url - user - password -
- Throws:
IOException
performHttpPost
public static org.apache.commons.httpclient.HttpMethod performHttpPost(String url,
InputStream content,
int timeout,
String user,
String password,
String contentType,
String encoding,
Map<String,String> header)
throws org.apache.commons.httpclient.HttpException,
IOException
- Parameters:
url - content - timeout - timeout in millisecondsuser - (can be null)password - (can be null)contentType - request content mime type (can be null)encoding - request encoding (can be null)header - not supported yet
- Returns:
- result of http post request
- Throws:
org.apache.commons.httpclient.HttpException
IOException
performHttpPost
public static org.apache.commons.httpclient.HttpMethod performHttpPost(String url,
String content,
int timeout,
String user,
String password,
String contentType,
String encoding,
Map<String,String> header)
throws org.apache.commons.httpclient.HttpException,
IOException
- Parameters:
url - content - timeout - timeout in millisecondsuser - (can null)password - (can null)contentType - request content mime type (can be null)encoding - request encoding (can be null)header - not supported yet
- Returns:
- result of http post request
- Throws:
org.apache.commons.httpclient.HttpException
IOException
performHttpPost
public static org.apache.commons.httpclient.HttpMethod performHttpPost(String url,
XMLFragment content,
int timeout,
String user,
String password,
Map<String,String> header)
throws org.apache.commons.httpclient.HttpException,
IOException
- Parameters:
url - content - timeout - timeout in millisecondsuser - (can null)password - (can null)header - not supported yet
- Returns:
- result of http post request
- Throws:
org.apache.commons.httpclient.HttpException
IOException
performHttpGet
public static org.apache.commons.httpclient.HttpMethod performHttpGet(String url,
String request,
int timeout,
String user,
String password,
Map<String,String> header)
throws org.apache.commons.httpclient.HttpException,
IOException
- Parameters:
url - e.g. http://localhost:8080/deegree/servicesrequest - e.g. service=WMS&request=GetCapabilitiestimeout - timeout in millisecondsuser - (can be null)password - (can be null)header - (not supported yet)
- Returns:
- result of http get request
- Throws:
org.apache.commons.httpclient.HttpException
IOException
addAuthenticationForKVP
public static String addAuthenticationForKVP(String url,
String user,
String password,
String sessionID)
- Parameters:
url - user - password - sessionID -
- Returns:
- URL with attached authentication information (if not null)
addAuthenticationForXML
public static XMLFragment addAuthenticationForXML(XMLFragment xml,
String user,
String password,
String sessionID)
- Parameters:
xml - user - password - sessionID -
- Returns:
- XML document with authentication information (if not null) as attributes of the root element
normalizeURL
public static String normalizeURL(URL url)
- Parameters:
url -
- Returns:
- URL as String with protocol and path but without request params
- Throws:
URISyntaxException
normalizeURL
public static String normalizeURL(String url)
- Parameters:
url -
- Returns:
- URL as String with protocol and path but without request params
- Throws:
URISyntaxException
an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org