org.carrot2.util.httpclient
Class HttpUtils

java.lang.Object
  extended by org.carrot2.util.httpclient.HttpUtils

public class HttpUtils
extends Object

Various utilities for working with HTTP data streams.


Nested Class Summary
static class HttpUtils.Response
          A static holder storing HTTP response fields.
 
Method Summary
static HttpUtils.Response doGET(String url, Collection<org.apache.http.NameValuePair> params, Collection<org.apache.http.Header> headers)
          Opens a HTTP/1.1 connection to the given URL using the GET method, decompresses compressed response streams, if supported by the server.
static HttpUtils.Response doGET(String url, Collection<org.apache.http.NameValuePair> params, Collection<org.apache.http.Header> headers, String user, String password)
          Opens a HTTP/1.1 connection to the given URL using the GET method, decompresses compressed response streams, if supported by the server.
static HttpUtils.Response doGET(String url, Collection<org.apache.http.NameValuePair> params, Collection<org.apache.http.Header> headers, String user, String password, int timeout)
          Opens a HTTP/1.1 connection to the given URL using the GET method, decompresses compressed response streams, if supported by the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

doGET

public static HttpUtils.Response doGET(String url,
                                       Collection<org.apache.http.NameValuePair> params,
                                       Collection<org.apache.http.Header> headers)
                                throws IOException
Opens a HTTP/1.1 connection to the given URL using the GET method, decompresses compressed response streams, if supported by the server.

Parameters:
url - The URL to open. The URL must be properly escaped, this method will not perform any escaping.
params - Query string parameters to be attached to the url.
headers - Any extra HTTP headers to add to the request.
Returns:
The HttpUtils.Response object. Note that entire payload is read and buffered so that the HTTP connection can be closed when leaving this method.
Throws:
IOException

doGET

public static HttpUtils.Response doGET(String url,
                                       Collection<org.apache.http.NameValuePair> params,
                                       Collection<org.apache.http.Header> headers,
                                       String user,
                                       String password)
                                throws IOException
Opens a HTTP/1.1 connection to the given URL using the GET method, decompresses compressed response streams, if supported by the server.

Parameters:
url - The URL to open. The URL must be properly escaped, this method will not perform any escaping.
params - Query string parameters to be attached to the url.
headers - Any extra HTTP headers to add to the request.
user - if not null, the user name to send during Basic Authentication
password - if not null, the password name to send during Basic Authentication
Returns:
The HttpUtils.Response object. Note that entire payload is read and buffered so that the HTTP connection can be closed when leaving this method.
Throws:
IOException

doGET

public static HttpUtils.Response doGET(String url,
                                       Collection<org.apache.http.NameValuePair> params,
                                       Collection<org.apache.http.Header> headers,
                                       String user,
                                       String password,
                                       int timeout)
                                throws IOException
Opens a HTTP/1.1 connection to the given URL using the GET method, decompresses compressed response streams, if supported by the server.

Parameters:
url - The URL to open. The URL must be properly escaped, this method will not perform any escaping.
params - Query string parameters to be attached to the url.
headers - Any extra HTTP headers to add to the request.
user - if not null, the user name to send during Basic Authentication
password - if not null, the password name to send during Basic Authentication
Returns:
The HttpUtils.Response object. Note that entire payload is read and buffered so that the HTTP connection can be closed when leaving this method.
Throws:
IOException


Copyright (c) Dawid Weiss, Stanislaw Osinski