Package org.gradle.caching.http

## Class HttpBuildCache

- java.lang.Object
- - org.gradle.caching.configuration.AbstractBuildCache
  - - org.gradle.caching.http.HttpBuildCache

- All Implemented Interfaces:
    `BuildCache`

      public class HttpBuildCache
      extends AbstractBuildCache

  Configuration object for the HTTP build cache. The build cache only supports BASIC authentication currently.

  Cache entries are loaded via GET and stored via PUT requests.

  For a GET request we expect a 200 or 404 response and for PUT we expect any 2xx response. Other responses are treated as recoverable or non-recoverable errors, depending on the status code. E.g. we treat authentication failures (401 and 409) as non-recoverable while an internal server error (500) is recoverable.
  Since:
    3.5

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `HttpBuildCache()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `credentials​(Action<? super HttpBuildCacheCredentials> configuration)` | Configures the credentials used to access the HTTP cache backend.
    `HttpBuildCacheCredentials` | `getCredentials()` | Returns the credentials used to access the HTTP cache backend.
    `java.net.URI` | `getUrl()` | Returns the URI to the cache.
    `boolean` | `isAllowInsecureProtocol()` | Specifies whether it is acceptable to communicate with a build cache over an insecure HTTP connection.
    `boolean` | `isAllowUntrustedServer()` | Specifies whether it is acceptable to communicate with an HTTP build cache backend with an untrusted SSL certificate.
    `void` | `setAllowInsecureProtocol​(boolean allowInsecureProtocol)` | Specifies whether it is acceptable to communicate with a build cache over an insecure HTTP connection.
    `void` | `setAllowUntrustedServer​(boolean allowUntrustedServer)` | Specifies whether it is acceptable to communicate with an HTTP build cache backend with an untrusted SSL certificate.
    `void` | `setUrl​(java.lang.String url)` | Sets the URL of the cache.
    `void` | `setUrl​(java.net.URI url)` | Sets the URL of the cache.
    `void` | `setUrl​(java.net.URL url)` | Sets the URL of the cache.

    - ### Methods inherited from class org.gradle.caching.configuration.AbstractBuildCache

      `isEnabled, isPush, setEnabled, setPush`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HttpBuildCache

          public HttpBuildCache()

  - ### Method Detail

    - #### getUrl

          @Nullable
          public java.net.URI getUrl()

      Returns the URI to the cache.

    - #### setUrl

          public void setUrl​(java.lang.String url)

      Sets the URL of the cache. The URL must end in a '/'.

    - #### setUrl

          public void setUrl​(java.net.URL url)
                      throws java.net.URISyntaxException

      Sets the URL of the cache. The URL must end in a '/'.
      Throws:
        `java.net.URISyntaxException`

    - #### setUrl

          public void setUrl​(@Nullable
                             java.net.URI url)

      Sets the URL of the cache. The URL must end in a '/'.

    - #### getCredentials

          public HttpBuildCacheCredentials getCredentials()

      Returns the credentials used to access the HTTP cache backend.

    - #### credentials

          public void credentials​(Action<? super HttpBuildCacheCredentials> configuration)

      Configures the credentials used to access the HTTP cache backend.

    - #### isAllowUntrustedServer

          public boolean isAllowUntrustedServer()

      Specifies whether it is acceptable to communicate with an HTTP build cache backend with an untrusted SSL certificate.

      The SSL certificate for the HTTP build cache backend may be untrusted since it is internally provisioned or a self-signed certificate.

      In such a scenario, you can either configure the build JVM environment to trust the certificate, or set this property to `true` to disable verification of the server's identity.

      Allowing communication with untrusted servers keeps data encrypted during transmission, but makes it easier for a man-in-the-middle to impersonate the intended server and capture data.

      This value has no effect if a server is specified using the HTTP protocol (i.e. has SSL disabled).

      Since:
        4.2

    - #### setAllowUntrustedServer

          public void setAllowUntrustedServer​(boolean allowUntrustedServer)

      Specifies whether it is acceptable to communicate with an HTTP build cache backend with an untrusted SSL certificate.

      The SSL certificate for the HTTP build cache backend may be untrusted since it is internally provisioned or a self-signed certificate.

      In such a scenario, you can either configure the build JVM environment to trust the certificate, or set this property to `true` to disable verification of the server's identity.

      Allowing communication with untrusted servers keeps data encrypted during transmission, but makes it easier for a man-in-the-middle to impersonate the intended server and capture data.

      This value has no effect if a server is specified using the HTTP protocol (i.e. has SSL disabled).

      Since:
        4.2

    - #### isAllowInsecureProtocol

          public boolean isAllowInsecureProtocol()

      Specifies whether it is acceptable to communicate with a build cache over an insecure HTTP connection.

      For security purposes this intentionally requires a user to opt-in to using insecure protocols on case by case basis.

      Gradle intentionally does not offer a global system/gradle property that allows a universal disable of this check.

      Allowing communication over insecure protocols allows for a man-in-the-middle to impersonate the intended server, and gives an attacker the ability to serve malicious executable code onto the system.

      See also: Want to take over the Java ecosystem? All you need is a MITM!

      Since:
        6.0

    - #### setAllowInsecureProtocol

          public void setAllowInsecureProtocol​(boolean allowInsecureProtocol)

      Specifies whether it is acceptable to communicate with a build cache over an insecure HTTP connection.
      Since:
        6.0
      See Also:
        `isAllowInsecureProtocol()`