Class TransportHttp

  • All Implemented Interfaces:
    AutoCloseable, PackTransport, WalkTransport

    public class TransportHttp
    extends HttpTransport
    implements WalkTransport, PackTransport
    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:
    • Method Detail

      • setUseSmartHttp

        public void setUseSmartHttp​(boolean on)
        Toggle whether or not smart HTTP transport should be used.

        This flag exists primarily to support backwards compatibility testing within a testing framework, there is no need to modify it in most applications.

        on - if true (default), smart HTTP is enabled.
      • setPreemptiveBasicAuthentication

        public void setPreemptiveBasicAuthentication​(String username,
                                                     String password)
        Sets preemptive Basic HTTP authentication. If the given username or password is empty or null, no preemptive authentication will be done. If username and password are set, they will override authority information from the URI ("user:password@").

        If the connection encounters redirects, the pre-authentication will be cleared if the redirect goes to a different host.

        username - to use
        password - to use
        IllegalStateException - if an HTTP/HTTPS connection has already been opened on this TransportHttp instance
      • close

        public void close()

        Close any resources used by this transport.

        If the remote repository is contacted by a network socket this method must close that network socket, disconnecting the two peers. If the remote repository is actually local (same system) this method must close any open file handles used to read the "remote" repository.

        AutoClosable.close() declares that it throws Exception. Implementers shouldn't throw checked exceptions. This override narrows the signature to prevent them from doing so.

        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in class Transport
      • setAdditionalHeaders

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