googleapis / googleapis/google-http-java-client

HttpClient RequestConfig cannot be set

Open
#1,107 3 comments 0 reactions 0 assignees View on GitHub
type: feature request
Dominant language
Java
Stars
1.4k
Forks
473
PR merge metrics
No merged PRs in 30d

Description

AWS ALB sticky sessions use a cookie format that is not compatible with the default Apache HttpClient cookie specification.

The remedy for this is to provide a RequestConfig with CookieSpec set to CookieSpecs.STANDARD. But, there appears to be no way for such a RequestConfig to be actually used in this library.

Currently, I use the following mechanism attempting to provide a RequestConfig:

```
var builder = ApacheHttpTransport
.newDefaultHttpClientBuilder()
.setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build());
HTTP_TRANSPORT = new ApacheHttpTransport(builder.build());
...
RequestFactoryPlain = HTTP_TRANSPORT.createRequestFactory();
...
HttpRequest request = RequestFactoryPlain.buildRequest(method, url, content);
```

This RequestConfig is however not used, as the ApacheHttpRequest constructor creates a custom request configuration for every request, preventing the HttpClient default request config from being used.

Is there a different mechanism that would allow me to provide a baseline RequestConfig? If not, can one be added - potentially by using the provided HttpClient RequestConfig as a baseline instead of ignoring it and overwriting the values in ApacheHttpRequest ctor?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.