vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

HttpClient supports request on a specified HttpConnection

Open coding4m opened this issue 3 years ago • 6 comments

Describe the feature

Allows HttpClient send a request on a specified HttpConnection.

Use cases

  • for reversed proxy we could bound the client connection to upstream connection (load balance or keeping the authentication context).

Contribution

may be something like:

new io.vertx.core.http.RequestOptions()
         .setConnection(HttpConnection or HttpClientConnection) // currently HttpClientConnection is defined at io.vertx.core.http.impl

coding4m avatar Mar 01 '22 01:03 coding4m

currently that is something you can do if you cast HttpConnection to HttpClientConnection and use createStream() and then use the stream API directly. You can have a look at Http1xClientConnectionTest.

We could think of having a way to attach HttpClientRequest and HttpClientResponse to a stream.

vietj avatar Mar 01 '22 08:03 vietj

the use case is to reuse the same HTTP client connection for a given HTTP server connection, is that right ?

vietj avatar Mar 01 '22 08:03 vietj

so we could cleanup and improve the HttpClientStream API which currently uses a mix of ByteBuf and Buffer (it would use only Buffer) to make it more usable.

vietj avatar Mar 01 '22 09:03 vietj

the use case is to reuse the same HTTP client connection for a given HTTP server connection, is that right ?

yes, that's right.

coding4m avatar Mar 01 '22 09:03 coding4m

so we could cleanup and improve the HttpClientStream API which currently uses a mix of ByteBuf and Buffer (it would use only Buffer) to make it more usable.

HttpClientStream defined at io.vertx.core.http.impl package. it seem like internal api.

could we define a simply api on HttpClient ?

coding4m avatar Mar 01 '22 09:03 coding4m

HttpClientConnection would be move to the io.vertx.core.http package and provide something like Future<HttpClientRequest> HttpConnection#request() that would schedule a request on this connection, how does that sound ?

vietj avatar May 03 '22 14:05 vietj

HttpClientConnection would be move to the io.vertx.core.http package and provide something like Future<HttpClientRequest> HttpConnection#request() that would schedule a request on this connection, how does that sound ?

LGTM, thanks.

coding4m avatar Nov 10 '22 03:11 coding4m