java.lang.Object
org.eclipse.jgit.transport.http.JDKHttpConnection
- All Implemented Interfaces:
HttpConnection
A
HttpConnection which simply
delegates every call to a HttpURLConnection. This is the
default implementation used by JGit- Since:
- 3.3
-
Field Summary
Fields inherited from interface org.eclipse.jgit.transport.http.HttpConnection
HTTP_11_MOVED_PERM, HTTP_11_MOVED_TEMP, HTTP_FORBIDDEN, HTTP_MOVED_PERM, HTTP_MOVED_TEMP, HTTP_NOT_AUTHORITATIVE, HTTP_NOT_FOUND, HTTP_OK, HTTP_SEE_OTHER, HTTP_UNAUTHORIZED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJDKHttpConnection(URL url) Constructor for JDKHttpConnection.protectedJDKHttpConnection(URL url, Proxy proxy) Constructor for JDKHttpConnection. -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(KeyManager[] km, TrustManager[] tm, SecureRandom random) Configure the connection so that it can be used for https communication.voidconnect()ConnectintGet content lengthGet content typegetHeaderField(String name) Get header field.Get map of header fieldsgetHeaderFields(String name) Get all values of given header field.Get input streamGet output streamGet request methodintGet response codeGet response messagegetURL()Get URLvoidsetChunkedStreamingMode(int chunklen) Set chunked streaming modevoidsetConnectTimeout(int timeout) Set connect timeoutvoidsetDoOutput(boolean dooutput) Set if to do outputvoidsetFixedLengthStreamingMode(int contentLength) Set fixed length streaming modevoidsetHostnameVerifier(HostnameVerifier hostnameverifier) Set theHostnameVerifierused during https communicationvoidsetInstanceFollowRedirects(boolean followRedirects) Set whether or not to follow HTTP redirects.voidsetReadTimeout(int timeout) Set read timeoutvoidsetRequestMethod(String method) Set request methodvoidsetRequestProperty(String key, String value) Set request propertyvoidsetUseCaches(boolean usecaches) Set if to use cachesbooleanWhether we use a proxy
-
Constructor Details
-
JDKHttpConnection
Constructor for JDKHttpConnection.- Parameters:
url- aURLobject.- Throws:
MalformedURLException- if URL is malformedIOException- if an IO error occurred
-
JDKHttpConnection
Constructor for JDKHttpConnection.- Parameters:
url- aURLobject.proxy- aProxyobject.- Throws:
MalformedURLException- if URL is malformedIOException- if an IO error occurred
-
-
Method Details
-
getResponseCode
Description copied from interface:HttpConnectionGet response code- Specified by:
getResponseCodein interfaceHttpConnection- Returns:
- the HTTP Status-Code, or -1
- Throws:
IOException- if an IO error occurred- See Also:
-
getURL
Description copied from interface:HttpConnectionGet URL- Specified by:
getURLin interfaceHttpConnection- Returns:
- the URL.
- See Also:
-
getResponseMessage
Description copied from interface:HttpConnectionGet response message- Specified by:
getResponseMessagein interfaceHttpConnection- Returns:
- the HTTP response message, or
null - Throws:
IOException- if an IO error occurred- See Also:
-
getHeaderFields
Description copied from interface:HttpConnectionGet map of header fields- Specified by:
getHeaderFieldsin interfaceHttpConnection- Returns:
- a Map of header fields
- See Also:
-
setRequestProperty
Description copied from interface:HttpConnectionSet request property- Specified by:
setRequestPropertyin interfaceHttpConnection- Parameters:
key- the keyword by which the request is known (e.g., "Accept").value- the value associated with it.- See Also:
-
setRequestMethod
Description copied from interface:HttpConnectionSet request method- Specified by:
setRequestMethodin interfaceHttpConnection- Parameters:
method- the HTTP method- Throws:
ProtocolException- if the method cannot be reset or if the requested method isn't valid for HTTP.- See Also:
-
setUseCaches
public void setUseCaches(boolean usecaches) Description copied from interface:HttpConnectionSet if to use caches- Specified by:
setUseCachesin interfaceHttpConnection- Parameters:
usecaches- abooleanindicating whether or not to allow caching- See Also:
-
setConnectTimeout
public void setConnectTimeout(int timeout) Description copied from interface:HttpConnectionSet connect timeout- Specified by:
setConnectTimeoutin interfaceHttpConnection- Parameters:
timeout- anintthat specifies the connect timeout value in milliseconds- See Also:
-
setReadTimeout
public void setReadTimeout(int timeout) Description copied from interface:HttpConnectionSet read timeout- Specified by:
setReadTimeoutin interfaceHttpConnection- Parameters:
timeout- anintthat specifies the timeout value to be used in milliseconds- See Also:
-
getContentType
Description copied from interface:HttpConnectionGet content type- Specified by:
getContentTypein interfaceHttpConnection- Returns:
- the content type of the resource that the URL references, or
nullif not known. - See Also:
-
getInputStream
Description copied from interface:HttpConnectionGet input stream- Specified by:
getInputStreamin interfaceHttpConnection- Returns:
- an input stream that reads from this open connection.
- Throws:
IOException- if an I/O error occurs while creating the input stream.- See Also:
-
getHeaderField
Description copied from interface:HttpConnectionGet header field. According to RFC 2616 header field names are case insensitive. Header fields defined as a comma separated list can have multiple header fields with the same field name. This method only returns one of these header fields. If you want the union of all values of all multiple header fields with the same field name then useHttpConnection.getHeaderFields(String)- Specified by:
getHeaderFieldin interfaceHttpConnection- Parameters:
name- the name of a header field.- Returns:
- the value of the named header field, or
nullif there is no such field in the header. - See Also:
-
getHeaderFields
Description copied from interface:HttpConnectionGet all values of given header field. According to RFC 2616 header field names are case insensitive. Header fields defined as a comma separated list can have multiple header fields with the same field name. This method does not validate if the given header field is defined as a comma separated list.- Specified by:
getHeaderFieldsin interfaceHttpConnection- Parameters:
name- the name of a header field.- Returns:
- the list of values of the named header field
-
getContentLength
public int getContentLength()Description copied from interface:HttpConnectionGet content length- Specified by:
getContentLengthin interfaceHttpConnection- Returns:
- the content length of the resource that this connection's URL
references,
-1if the content length is not known, or if the content length is greater than Integer.MAX_VALUE. - See Also:
-
setInstanceFollowRedirects
public void setInstanceFollowRedirects(boolean followRedirects) Description copied from interface:HttpConnectionSet whether or not to follow HTTP redirects.- Specified by:
setInstanceFollowRedirectsin interfaceHttpConnection- Parameters:
followRedirects- abooleanindicating whether or not to follow HTTP redirects.- See Also:
-
setDoOutput
public void setDoOutput(boolean dooutput) Description copied from interface:HttpConnectionSet if to do output- Specified by:
setDoOutputin interfaceHttpConnection- Parameters:
dooutput- the new value.- See Also:
-
setFixedLengthStreamingMode
public void setFixedLengthStreamingMode(int contentLength) Description copied from interface:HttpConnectionSet fixed length streaming mode- Specified by:
setFixedLengthStreamingModein interfaceHttpConnection- Parameters:
contentLength- The number of bytes which will be written to the OutputStream.- See Also:
-
getOutputStream
Description copied from interface:HttpConnectionGet output stream- Specified by:
getOutputStreamin interfaceHttpConnection- Returns:
- an output stream that writes to this connection.
- Throws:
IOException- if an IO error occurred- See Also:
-
setChunkedStreamingMode
public void setChunkedStreamingMode(int chunklen) Description copied from interface:HttpConnectionSet chunked streaming mode- Specified by:
setChunkedStreamingModein interfaceHttpConnection- Parameters:
chunklen- The number of bytes to write in each chunk. If chunklen is less than or equal to zero, a default value will be used.- See Also:
-
getRequestMethod
Description copied from interface:HttpConnectionGet request method- Specified by:
getRequestMethodin interfaceHttpConnection- Returns:
- the HTTP request method
- See Also:
-
usingProxy
public boolean usingProxy()Description copied from interface:HttpConnectionWhether we use a proxy- Specified by:
usingProxyin interfaceHttpConnection- Returns:
- a boolean indicating if the connection is using a proxy.
- See Also:
-
connect
Description copied from interface:HttpConnectionConnect- Specified by:
connectin interfaceHttpConnection- Throws:
IOException- if an IO error occurred- See Also:
-
setHostnameVerifier
Description copied from interface:HttpConnectionSet theHostnameVerifierused during https communication- Specified by:
setHostnameVerifierin interfaceHttpConnection- Parameters:
hostnameverifier- aHostnameVerifierobject.
-
configure
public void configure(KeyManager[] km, TrustManager[] tm, SecureRandom random) throws NoSuchAlgorithmException, KeyManagementException Description copied from interface:HttpConnectionConfigure the connection so that it can be used for https communication.- Specified by:
configurein interfaceHttpConnection- Parameters:
km- the keymanager managing the key material used to authenticate the local SSLSocket to its peertm- the trustmanager responsible for managing the trust material that is used when making trust decisions, and for deciding whether credentials presented by a peer should be accepted.random- the source of randomness for this generator or null. SeeSSLContext.init(KeyManager[], TrustManager[], SecureRandom)- Throws:
NoSuchAlgorithmException- if algorithm isn't availableKeyManagementException- if key management failed
-