Skip to content

Allow Users To Customize HttpClient #2410

@hpoettker

Description

@hpoettker

Problem description

I can use the config server with Bitbucket (v8.19.1) over http and authenticate with a token by exposing a bean like this:

@Bean
public TransportConfigCallback tokenAuthCallback() {
  var headers = Map.of("Authorization", "Bearer " + TOKEN);
  return transport -> {
    if (transport instanceof TransportHttp transportHttp) {
      transportHttp.setAdditionalHeaders(headers);
    }
  };
}

This works generally fine but produces a warning like the following in the config service on every http connection to the repository:

WARN o.a.h.c.protocol.ResponseProcessCookies : Invalid cookie header: "Set-Cookie: BITBUCKETSESSIONID=XXXX; Max-Age=1209600; Expires=Thu, 09 May 2024 13:45:48 GMT; Path=/; Secure; HttpOnly". Invalid 'expires' attribute: Thu, 09 May 2024 13:45:48 GMT

Root cause

The problem can be fixed by setting the cookie spec of the request config to STANDARD with code like this (e.g. in HttpClient4Support):

httpClientBuilder.setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD))

Feature request

Setting the cookie spec of the underlying HttpClient is not impossible but rather elaborate at the moment (e.g. by redefining the implementation of ConfigurableHttpConnectionFactory). It would be great if JGitEnvironmentProperties had a property cookieSpec that would allow to set the cookie spec as needed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions