/** * Execute an HTTP request. * * @param context * Context associated with the request. * @return * Observable with the response of the request. */ Observable<HttpClientResponse<ByteBuf>> execute(final RequestContext context) { final HttpLogEntry entry = context.entry(); final HttpClient<ByteBuf, ByteBuf> client = getClient(context); entry.mark("start"); entry.withRemoteAddr(context.server().host()); entry.withRemotePort(context.server().port()); return client.submit(context.request()) .doOnNext(new Action1<HttpClientResponse<ByteBuf>>() { @Override public void call(HttpClientResponse<ByteBuf> res) { update(entry, res); HttpLogEntry.logClientRequest(entry); } }) .doOnError(new Action1<Throwable>() { @Override public void call(Throwable throwable) { update(entry, throwable); HttpLogEntry.logClientRequest(entry); } }) .doOnTerminate(Actions.empty()); }