> + this.creds = ((Supplier)Preconditions.checkNotNull(creds, "creds"));
> + this.apiVersion = apiVersion;
> + }
> +
> + public HttpRequest filter(HttpRequest request) throws HttpException
> + {
> + Credentials currentCreds =
> (Credentials)Preconditions.checkNotNull(this.creds.get(), "credential
> supplier returned null");
> + String acceptType = request.getFirstHeaderOrNull("Accept") == null ?
> "application/*+xml" : request.getFirstHeaderOrNull("Accept");
> +
> + String version = ";version=" + this.apiVersion;
> + String acceptHeader = acceptType + version;
> +
> + request =
> ((HttpRequest.Builder)request.toBuilder().replaceHeader("Accept", new
> String[] { acceptHeader })).build();
> +
> + return
> ((HttpRequest.Builder)request.toBuilder().replaceHeader("Authorization", new
> String[] { BasicAuthentication.basic(currentCreds.identity,
> currentCreds.credential) })).build();
> + }
Could this class just extend the `BasicAuthentication` filter and just add the
accept header after the parent has done its work?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/418/files#r14185496