@Override
    public void apply(final ApiRequest request, final IPolicyContext context, final Object config,
            final IPolicyChain<ApiRequest> chain) {
        final IHttpClientComponent httpClientComponent = context.getComponent(IHttpClientComponent.class);
        String endpoint = System.getProperty("apiman.test.gateway.endpoints.echo"); //$NON-NLS-1$
        IHttpClientRequest clientRequest = httpClientComponent.request(endpoint, HttpMethod.GET, new IAsyncResultHandler<IHttpClientResponse>() {
            @Override
            public void handle(IAsyncResult<IHttpClientResponse> result) {
                if (result.isError()) {
                    request.getHeaders().put("X-HttpClient-Result", "Error"); //$NON-NLS-1$ //$NON-NLS-2$
                    request.getHeaders().put("X-HttpClient-Error", result.getError().getMessage()); //$NON-NLS-1$
                } else {
                    IHttpClientResponse clientResponse = result.getResult();
                    request.getHeaders().put("X-HttpClient-Result", "Success"); //$NON-NLS-1$ //$NON-NLS-2$
                    request.getHeaders().put("X-HttpClient-Response-Code", String.valueOf(clientResponse.getResponseCode())); //$NON-NLS-1$
                    request.getHeaders().put("X-HttpClient-Response-Message", String.valueOf(clientResponse.getResponseMessage())); //$NON-NLS-1$
                    clientResponse.close();
                }
                chain.doApply(request);
            }
        });
        clientRequest.addHeader("X-Test", getClass().getSimpleName()); //$NON-NLS-1$
        clientRequest.end();
    }
@see io.apiman.gateway.engine.policy.IPolicy#apply(io.apiman.gateway.engine.beans.ApiRequest, io.apiman.gateway.engine.policy.IPolicyContext, java.lang.Object, io.apiman.gateway.engine.policy.IPolicyChain)
gateway/test/src/test/java/io/apiman/gateway/test/policies/SimpleHttpClientPolicy.java