Class ChfHttpTransport


  • public class ChfHttpTransport
    extends com.google.api.client.http.HttpTransport
    Implementation of the Google Cloud API HttpTransport interface using CHF. This allows CHF to be used as the HTTP client library for REST calls to Google Cloud Platform. Example:
    
     Handler chfHandler = new HttpClientHandler();
     Supplier<Context> contextSupplier = RootContext::new;
     HttpTransportFactory httpTransportFactory = () -> new ChfHttpTransport(chfHandler, contextSupplier);
    
     GoogleCredentials credentials = ServiceAccountCredentials.fromStream(
             new FileInputStream("/engineering-devops-afce7aa71027.json"), httpTransportFactory);
     credentials = credentials.createScoped("https://www.googleapis.com/auth/cloudkms");
     

    Note: it is not possible to change the transport used for RPC calls to GCP services, so this will only be used to obtain OAuth access tokens and other auxiliary requests.

    • Constructor Detail

      • ChfHttpTransport

        public ChfHttpTransport​(Handler httpHandler,
                                Supplier<Context> context)
        Initialises the transport with the given CHF client handler and context supplier.
        Parameters:
        httpHandler - the CHF client handler.
        context - a supplier for the context argument to use on requests.
    • Method Detail

      • buildRequest

        protected com.google.api.client.http.LowLevelHttpRequest buildRequest​(String method,
                                                                              String url)
        Specified by:
        buildRequest in class com.google.api.client.http.HttpTransport