org.eclipse.jgit.util
Class HttpSupport

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

public class HttpSupport
extends java.lang.Object

Extra utilities to support usage of HTTP.


Method Summary
static void encode(java.lang.StringBuilder urlstr, java.lang.String key)
          URL encode a value string into an output buffer.
static java.net.Proxy proxyFor(java.net.ProxySelector proxySelector, java.net.URL u)
          Determine the proxy server (if any) needed to obtain a URL.
static int response(java.net.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
 

Method Detail

encode

public static void encode(java.lang.StringBuilder urlstr,
                          java.lang.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(java.net.HttpURLConnection c)
                    throws java.io.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:
java.io.IOException - communications error prevented obtaining the response code.

proxyFor

public static java.net.Proxy proxyFor(java.net.ProxySelector proxySelector,
                                      java.net.URL u)
                               throws java.net.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:
java.net.ConnectException - the proxy could not be computed as the supplied URL could not be read. This failure should never occur.