OpenFeign Request Interceptor Not Adding Content-Length and Host Headers for application/x-www-form-urlencoded Content-Type

30 views Asked by At

I've encountered an issue with an OpenFeign request interceptor where the "Content-Length" and "Host" headers are not being added when making requests with the "application/x-www-form-urlencoded" content type. The interceptor is primarily responsible for adding the necessary headers such as content type, client ID, and client secret.

Here's a simplified version of the request interceptor:

@Slf4j
@RequiredArgsConstructor
public class CustomRequestInterceptor implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate requestTemplate) {
        log.info("Feign invoked");
        // adding token header content type
        requestTemplate.header("content-type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        requestTemplate.header("Client-Id", "fdjfldjlfdjlfd");
        requestTemplate.header("Client-Secret", "ljfjdlfjdl");
    }
}

Despite the interceptor adding the necessary headers, it seems that "Content-Length" and "Host" are not included in the actual request.

Is there anything I might be missing or misunderstanding about how OpenFeign handles these headers when a request interceptor is in use? Any suggestions on how to ensure the inclusion of "Content-Length" and "Host" headers for requests with the "application/x-www-form-urlencoded" content type?

I tried the following approches

  • changed default http cleint
  • removed request interceptors
0

There are 0 answers