Package org.eclipse.jgit.transport.http
Interface HttpConnection
- All Known Implementing Classes:
HttpClientConnection
,JDKHttpConnection
public interface HttpConnection
The interface of connections used during HTTP communication. This interface
is that subset of the interface exposed by
HttpURLConnection
which is used by JGit- Since:
- 3.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
HTTP 1.1 additional "permanent redirect" status code; value = 308.static final int
HTTP 1.1 additional "temporary redirect" status code; value = 307.static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(KeyManager[] km, TrustManager[] tm, SecureRandom random) Configure the connection so that it can be used for https communication.void
connect()
Connectint
Get 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 methodint
Get response codeGet response messagegetURL()
Get URLvoid
setChunkedStreamingMode
(int chunklen) Set chunked streaming modevoid
setConnectTimeout
(int timeout) Set connect timeoutvoid
setDoOutput
(boolean dooutput) Set if to do outputvoid
setFixedLengthStreamingMode
(int contentLength) Set fixed length streaming modevoid
setHostnameVerifier
(HostnameVerifier hostnameverifier) Set theHostnameVerifier
used during https communicationvoid
setInstanceFollowRedirects
(boolean followRedirects) Set whether or not to follow HTTP redirects.void
setReadTimeout
(int timeout) Set read timeoutvoid
setRequestMethod
(String method) Set request methodvoid
setRequestProperty
(String key, String value) Set request propertyvoid
setUseCaches
(boolean usecaches) Set if to use cachesboolean
Whether we use a proxy
-
Field Details
-
HTTP_OK
static final int HTTP_OK- See Also:
-
HTTP_NOT_AUTHORITATIVE
static final int HTTP_NOT_AUTHORITATIVE- Since:
- 5.8
- See Also:
-
HTTP_MOVED_PERM
static final int HTTP_MOVED_PERM- Since:
- 4.7
- See Also:
-
HTTP_MOVED_TEMP
static final int HTTP_MOVED_TEMP- Since:
- 4.9
- See Also:
-
HTTP_SEE_OTHER
static final int HTTP_SEE_OTHER- Since:
- 4.9
- See Also:
-
HTTP_11_MOVED_TEMP
static final int HTTP_11_MOVED_TEMPHTTP 1.1 additional "temporary redirect" status code; value = 307.- Since:
- 4.9
- See Also:
-
HTTP_11_MOVED_PERM
static final int HTTP_11_MOVED_PERMHTTP 1.1 additional "permanent redirect" status code; value = 308.- Since:
- 5.8
- See Also:
-
HTTP_NOT_FOUND
static final int HTTP_NOT_FOUND- See Also:
-
HTTP_UNAUTHORIZED
static final int HTTP_UNAUTHORIZED- See Also:
-
HTTP_FORBIDDEN
static final int HTTP_FORBIDDEN- See Also:
-
-
Method Details
-
getResponseCode
Get response code- Returns:
- the HTTP Status-Code, or -1
- Throws:
IOException
- See Also:
-
getURL
URL getURL()Get URL- Returns:
- the URL.
- See Also:
-
getResponseMessage
Get response message- Returns:
- the HTTP response message, or
null
- Throws:
IOException
- See Also:
-
getHeaderFields
Get map of header fields- Returns:
- a Map of header fields
- See Also:
-
setRequestProperty
Set request property- Parameters:
key
- the keyword by which the request is known (e.g., "Accept
").value
- the value associated with it.- See Also:
-
setRequestMethod
Set request method- Parameters:
method
- the HTTP method- Throws:
ProtocolException
- if the method cannot be reset or if the requested method isn't valid for HTTP.ProtocolException
- if any.- See Also:
-
setUseCaches
void setUseCaches(boolean usecaches) Set if to use caches- Parameters:
usecaches
- aboolean
indicating whether or not to allow caching- See Also:
-
setConnectTimeout
void setConnectTimeout(int timeout) Set connect timeout- Parameters:
timeout
- anint
that specifies the connect timeout value in milliseconds- See Also:
-
setReadTimeout
void setReadTimeout(int timeout) Set read timeout- Parameters:
timeout
- anint
that specifies the timeout value to be used in milliseconds- See Also:
-
getContentType
String getContentType()Get content type- Returns:
- the content type of the resource that the URL references, or
null
if not known. - See Also:
-
getInputStream
Get input stream- Returns:
- an input stream that reads from this open connection.
- Throws:
IOException
- if an I/O error occurs while creating the input stream.IOException
- if any.- See Also:
-
getHeaderField
Get header field. According toinvalid @link
{@link <a href="https://tools.ietf.org/html/rfc2616#section-4.2">RFC
getHeaderFields(String)
- Parameters:
name
- the name of a header field.- Returns:
- the value of the named header field, or
null
if there is no such field in the header. - See Also:
-
getHeaderFields
Get all values of given header field. According toinvalid @link
{@link <a href="https://tools.ietf.org/html/rfc2616#section-4.2">RFC
- Parameters:
name
- the name of a header field.- Returns:
- the list of values of the named header field
- Since:
- 5.2
-
getContentLength
int getContentLength()Get content length- Returns:
- the content length of the resource that this connection's URL
references,
-1
if the content length is not known, or if the content length is greater than Integer.MAX_VALUE. - See Also:
-
setInstanceFollowRedirects
void setInstanceFollowRedirects(boolean followRedirects) Set whether or not to follow HTTP redirects.- Parameters:
followRedirects
- aboolean
indicating whether or not to follow HTTP redirects.- See Also:
-
setDoOutput
void setDoOutput(boolean dooutput) Set if to do output- Parameters:
dooutput
- the new value.- See Also:
-
setFixedLengthStreamingMode
void setFixedLengthStreamingMode(int contentLength) Set fixed length streaming mode- Parameters:
contentLength
- The number of bytes which will be written to the OutputStream.- See Also:
-
getOutputStream
Get output stream- Returns:
- an output stream that writes to this connection.
- Throws:
IOException
- See Also:
-
setChunkedStreamingMode
void setChunkedStreamingMode(int chunklen) Set chunked streaming mode- 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
String getRequestMethod()Get request method- Returns:
- the HTTP request method
- See Also:
-
usingProxy
boolean usingProxy()Whether we use a proxy- Returns:
- a boolean indicating if the connection is using a proxy.
- See Also:
-
connect
Connect- Throws:
IOException
- See Also:
-
configure
void configure(KeyManager[] km, TrustManager[] tm, SecureRandom random) throws NoSuchAlgorithmException, KeyManagementException Configure the connection so that it can be used for https communication.- 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
KeyManagementException
-
setHostnameVerifier
void setHostnameVerifier(HostnameVerifier hostnameverifier) throws NoSuchAlgorithmException, KeyManagementException Set theHostnameVerifier
used during https communication- Parameters:
hostnameverifier
- aHostnameVerifier
object.- Throws:
NoSuchAlgorithmException
KeyManagementException
-