HttpClient unable to handle 100 continue??

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

HttpClient unable to handle 100 continue??

dhilliprasad
This post was updated on .
I am new to ratpack. As part of the ratpack app we have an endpoint which makes a call to REST endpoint using HttpClient. The endpoint actually flow to F5 load balancer -> apache -> application.

While testing the ratpack endpoint, few requests will just work fine and all of a sudden http client will receive 100 from REST endpoint. when this happens ratpack request will timeout based on the timeout setting we have.

Here is the source code, Not sure if implementation is proper or not

@Slf4j
class IdValidationsResource extends GroovyChainAction {

    public static final String TOKEN_ID_VALIDATION_ENDPOINT = "/validation/id_validations"

    @Inject
    ValidationsService validationsService

    @Override
    void execute() {
        def chain = post {
            ValidationsServiceConfig validationsServiceConfig = context.get(ValidationsServiceConfig)
            def proxyUri = URI.create(validationsServiceConfig.tokenServiceBaseUrlOrVip
                    + TOKEN_ID_VALIDATION_ENDPOINT)

            request.body.then {
                byte[] bytes = it.bytes;
                log.info('Proxying call for token id validation: {}', new String(bytes))
                validationsService.httpClient.request(proxyUri) { RequestSpec spec ->
                    spec.headers.add("Content-Type", "application/json")
                    spec.body.bytes(bytes)
                    spec.post()
                } onError {
                    log.error("exception in processing the request : ", it)
                    response.status(HttpResponseStatus.REQUEST_TIMEOUT.code())
                    response.contentType(JsonUtils.JSON_CONTENT_TYPE)
                    render(Jackson.json(["message": "failed to proxy the id validation"]))
                } then { ReceivedResponse receivedResponse ->
                    log.info("Proxy response status for token id validation : {} ", receivedResponse.statusCode) //here is where i see an 100 continue at times
                    receivedResponse.forwardTo(response)
                }
            }
        }
    }
}

Any help would be much appreciated. Thanks in advance