org.eclipse.jgit.util
Class HttpSupport

java.lang.Object
  extended by org.eclipse.jgit.util.HttpSupport

public class HttpSupport
extends Object

Extra utilities to support usage of HTTP.


Field Summary
static String ENCODING_GZIP
          The gzip encoding value for HDR_ACCEPT_ENCODING.
static String HDR_ACCEPT
          The Accept header.
static String HDR_ACCEPT_ENCODING
          The Accept-Encoding header.
static String HDR_ACCEPT_RANGES
          The Accept-Ranges header.
static String HDR_AUTHORIZATION
          The Authorization header.
static String HDR_CACHE_CONTROL
          The Cache-Control header.
static String HDR_CONTENT_ENCODING
          The Content-Encoding header.
static String HDR_CONTENT_LENGTH
          The Content-Length header.
static String HDR_CONTENT_RANGE
          The Content-Range header.
static String HDR_CONTENT_TYPE
          The Content-Type header.
static String HDR_DATE
          The Date header.
static String HDR_ETAG
          The ETag header.
static String HDR_EXPIRES
          The Expires header.
static String HDR_IF_MODIFIED_SINCE
          The If-Modified-Since header.
static String HDR_IF_NONE_MATCH
          The If-None-Match header.
static String HDR_IF_RANGE
          The If-Range header.
static String HDR_LAST_MODIFIED
          The Last-Modified header.
static String HDR_PRAGMA
          The Pragma header.
static String HDR_RANGE
          The Range header.
static String HDR_USER_AGENT
          The User-Agent header.
static String HDR_WWW_AUTHENTICATE
          The WWW-Authenticate header.
static String METHOD_GET
          The GET HTTP method.
static String METHOD_POST
          The POST HTTP method.
static String TEXT_PLAIN
          The standard text/plain MIME type.
 
Method Summary
static void encode(StringBuilder urlstr, String key)
          URL encode a value string into an output buffer.
static Proxy proxyFor(ProxySelector proxySelector, URL u)
          Determine the proxy server (if any) needed to obtain a URL.
static int response(HttpURLConnection c)
          Get the HTTP response code from the request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METHOD_GET

public static final String METHOD_GET
The GET HTTP method.

See Also:
Constant Field Values

METHOD_POST

public static final String METHOD_POST
The POST HTTP method.

See Also:
Constant Field Values

HDR_CACHE_CONTROL

public static final String HDR_CACHE_CONTROL
The Cache-Control header.

See Also:
Constant Field Values

HDR_PRAGMA

public static final String HDR_PRAGMA
The Pragma header.

See Also:
Constant Field Values

HDR_USER_AGENT

public static final String HDR_USER_AGENT
The User-Agent header.

See Also:
Constant Field Values

HDR_DATE

public static final String HDR_DATE
The Date header.

See Also:
Constant Field Values

HDR_EXPIRES

public static final String HDR_EXPIRES
The Expires header.

See Also:
Constant Field Values

HDR_ETAG

public static final String HDR_ETAG
The ETag header.

See Also:
Constant Field Values

HDR_IF_NONE_MATCH

public static final String HDR_IF_NONE_MATCH
The If-None-Match header.

See Also:
Constant Field Values

HDR_LAST_MODIFIED

public static final String HDR_LAST_MODIFIED
The Last-Modified header.

See Also:
Constant Field Values

HDR_IF_MODIFIED_SINCE

public static final String HDR_IF_MODIFIED_SINCE
The If-Modified-Since header.

See Also:
Constant Field Values

HDR_ACCEPT

public static final String HDR_ACCEPT
The Accept header.

See Also:
Constant Field Values

HDR_CONTENT_TYPE

public static final String HDR_CONTENT_TYPE
The Content-Type header.

See Also:
Constant Field Values

HDR_CONTENT_LENGTH

public static final String HDR_CONTENT_LENGTH
The Content-Length header.

See Also:
Constant Field Values

HDR_CONTENT_ENCODING

public static final String HDR_CONTENT_ENCODING
The Content-Encoding header.

See Also:
Constant Field Values

HDR_CONTENT_RANGE

public static final String HDR_CONTENT_RANGE
The Content-Range header.

See Also:
Constant Field Values

HDR_ACCEPT_RANGES

public static final String HDR_ACCEPT_RANGES
The Accept-Ranges header.

See Also:
Constant Field Values

HDR_IF_RANGE

public static final String HDR_IF_RANGE
The If-Range header.

See Also:
Constant Field Values

HDR_RANGE

public static final String HDR_RANGE
The Range header.

See Also:
Constant Field Values

HDR_ACCEPT_ENCODING

public static final String HDR_ACCEPT_ENCODING
The Accept-Encoding header.

See Also:
Constant Field Values

ENCODING_GZIP

public static final String ENCODING_GZIP
The gzip encoding value for HDR_ACCEPT_ENCODING.

See Also:
Constant Field Values

TEXT_PLAIN

public static final String TEXT_PLAIN
The standard text/plain MIME type.

See Also:
Constant Field Values

HDR_AUTHORIZATION

public static final String HDR_AUTHORIZATION
The Authorization header.

See Also:
Constant Field Values

HDR_WWW_AUTHENTICATE

public static final String HDR_WWW_AUTHENTICATE
The WWW-Authenticate header.

See Also:
Constant Field Values
Method Detail

encode

public static void encode(StringBuilder urlstr,
                          String key)
URL encode a value string into an output buffer.

Parameters:
urlstr - the output buffer.
key - value which must be encoded to protected special characters.

response

public static int response(HttpURLConnection c)
                    throws IOException
Get the HTTP response code from the request.

Roughly the same as c.getResponseCode() but the ConnectException is translated to be more understandable.

Parameters:
c - connection the code should be obtained from.
Returns:
r HTTP status code, usually 200 to indicate success. See HttpURLConnection for other defined constants.
Throws:
IOException - communications error prevented obtaining the response code.

proxyFor

public static Proxy proxyFor(ProxySelector proxySelector,
                             URL u)
                      throws ConnectException
Determine the proxy server (if any) needed to obtain a URL.

Parameters:
proxySelector - proxy support for the caller.
u - location of the server caller wants to talk to.
Returns:
proxy to communicate with the supplied URL.
Throws:
ConnectException - the proxy could not be computed as the supplied URL could not be read. This failure should never occur.


Copyright © 2012. All Rights Reserved.