Top Description Inners Fields Constructors Methods
org.eclipse.jgit.transport

public Class TransportHttp

extends HttpTransport
implements WalkTransport, PackTransport
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.transport.PackTransport, org.eclipse.jgit.transport.WalkTransport
Static Imports
java.nio.charset.StandardCharsets.UTF_8, org.eclipse.jgit.lib.Constants.HEAD, .Constants.INFO_ALTERNATES, .Constants.INFO_HTTP_ALTERNATES, org.eclipse.jgit.util.HttpSupport.ENCODING_GZIP, .HttpSupport.ENCODING_X_GZIP, .HttpSupport.HDR_ACCEPT, .HttpSupport.HDR_ACCEPT_ENCODING, .HttpSupport.HDR_CONTENT_ENCODING, .HttpSupport.HDR_CONTENT_TYPE, .HttpSupport.HDR_COOKIE, .HttpSupport.HDR_LOCATION, .HttpSupport.HDR_PRAGMA, .HttpSupport.HDR_SET_COOKIE, .HttpSupport.HDR_SET_COOKIE2, .HttpSupport.HDR_USER_AGENT, .HttpSupport.HDR_WWW_AUTHENTICATE, .HttpSupport.METHOD_GET, .HttpSupport.METHOD_POST

Transport over HTTP and FTP protocols.

If the transport is using HTTP and the remote HTTP service is Git-aware (speaks the "smart-http protocol") this client will automatically take advantage of the additional Git-specific HTTP extensions. If the remote service does not support these extensions, the client will degrade to direct file fetching.

If the remote (server side) repository does not have the specialized Git support, object files are retrieved directly through standard HTTP GET (or binary FTP GET) requests. This make it easy to serve a Git repository through a standard web host provider that does not offer specific support for Git.

See Also
WalkFetchConnection

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
TransportHttp.AcceptEncoding

Accept-Encoding header in the HTTP request (https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).

private static class
pack-priv class
pack-priv class
TransportHttp.LongPollService

Service for maintaining a single long-poll connection.

pack-priv class
TransportHttp.MultiRequestService

State required to speak multiple HTTP requests with the remote.

pack-priv abstract class
TransportHttp.Service

Basic service for sending and receiving HTTP requests.

pack-priv class
pack-priv class

Field Summary

Modifier and TypeField and Description
private HttpAuthMethod
private URL
private final NetscapeCookieFile
cookieFile

All stored cookies bound to this repo (independent of the baseUrl)

private URIish
currentUri

The current URI we're talking to.

private HttpConnectionFactory
private boolean
private HttpConnectionFactory2.GitSession
private Map<String, String>
private final HttpConfig
private static final Logger
private URL
pack-priv static final TransportProtocol
pack-priv static final TransportProtocol
private final ProxySelector
private final Set<HttpCookie>
relevantCookies

The cookies to be sent with each request to the given baseUrl.

private boolean
private boolean
private static final String
private static final String
private boolean
private static final byte[]
Inherited from org.eclipse.jgit.transport.HttpTransport:
connectionFactory

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
TransportHttp(URIish
URI to create a HTTP transport for
uri
)

Create a minimal HTTP transport with default configuration values.

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
addHeaders(HttpConnection
The target HttpConnection
conn
,
List<String>
A list of header strings
headersToAdd
)

Adds a list of header strings to the connection.

private HttpAuthMethod
public void
close()

Implements abstract org.eclipse.jgit.transport.Transport.close.

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

private HttpConnection
connect(String service)

private HttpConnection
connect(String service, TransferConfig.ProtocolVersion protocolVersion)

private TransportHttp.CredentialItems
private NoRemoteRepositoryException
private List<HttpCookie>
extractCookies(String headerKey, List<String> headerValues)

private static Set<HttpCookie>
private static Set<HttpCookie>

Returns:

only the cookies from allCookies which are relevant (i.e. are not expired, have a matching domain, have a matching path and have a matching secure attribute)
filterCookies
(Set<HttpCookie>
a list of cookies.
allCookies
,
URL
the url for which to filter the list of cookies.
url
)

public Map<String, String>

Returns:

unmodifiable map of additional name:values that are set as headers on the HTTP connection
getAdditionalHeaders
()

Get additional headers on the HTTP connection

private FetchConnection
getConnection(HttpConnection c, InputStream in, String service, Collection<RefSpec> refSpecs, String... additionalPatterns)

private NetscapeCookieFile
public HttpConnectionFactory
getHttpConnectionFactory()

Retrieves the HttpConnectionFactory used by this TransportHttp instance.

private URL
private void
protected HttpConnection

Returns:

the HTTP connection
httpOpen
(String
HTTP request method
method
,
URL
url of the HTTP connection
u
,
TransportHttp.AcceptEncoding
accept-encoding header option
acceptEncoding
)

Open an HTTP connection.

private boolean
private boolean
private boolean
isValidRedirect(URL current, String next, String checkFor)

pack-priv static boolean

Returns:

true if they domain-match; false if not
matchesCookieDomain
(String
the host to compare against the cookieDomain
host
,
String
the domain to compare against
cookieDomain
)

The utility method to check whether a host name is in a cookie's domain or not.

pack-priv static boolean

Returns:

true if they path-match; false if not
matchesCookiePath
(String
the path to check
path
,
String
the cookie's path
cookiePath
)

The utility method to check whether a path is matching a cookie path domain or not.

private WalkFetchConnection
public FetchConnection
openFetch()

Implements abstract org.eclipse.jgit.transport.Transport.openFetch.

Begins a new connection for fetching from the remote repository.

public FetchConnection
openFetch(Collection<RefSpec> refSpecs, String...
that will be set as ref prefixes if the server supports git protocol V2; null values are ignored
additionalPatterns
)

Overrides org.eclipse.jgit.transport.Transport.openFetch.

Begins a new connection for fetching from the remote repository.

pack-priv final InputStream
public PushConnection
openPush()

Implements abstract org.eclipse.jgit.transport.Transport.openPush.

Begins a new connection for pushing into the remote repository.

pack-priv void
private void
private URIish
redirect(URL currentUrl, String location, String checkFor, int redirects)

public void
setAdditionalHeaders(Map<String, String>
a map of name:values that are to be set as headers on the HTTP connection
headers
)

Set additional headers on the HTTP connection

private void
public void
setHttpConnectionFactory(HttpConnectionFactory customFactory)

Sets the HttpConnectionFactory to be used by this TransportHttp instance.

public void
setPreemptiveBasicAuthentication(String
to use
username
,
String
to use
password
)

Sets preemptive Basic HTTP authentication.

protected void
public void
setUseSmartHttp(boolean
if true (default), smart HTTP is enabled.
on
)

Toggle whether or not smart HTTP transport should be used.

private PushConnection
private BufferedReader
private URL
toURL(URIish urish)

private boolean
private void
updateSslVerify(StoredConfig config, boolean value)

private void
updateSslVerifyUser(boolean value)

pack-priv IOException
wrongContentType(String expType, String actType)

Inherited from org.eclipse.jgit.transport.HttpTransport:
getConnectionFactorysetConnectionFactory