I am having below requirements with respect to http2. 1) While intiating client side http connection, I should be able to set Max_concurrent_streams supported by http2 server, and handle failure conditions accordingly.
2) Get stream ID of stream and assign priorities.
I checked okhttp client and Java11 http client. But couldnt find any way to achieve the same.
Please let me know is there any way to achieve these.
If you need to deal with low-level details of the HTTP/2 protocol, you can use Jetty's HTTP2Client
.
Note that it's the server that decides the max number of concurrent streams it can support, and the client cannot modify that value.
The client can send to the server the max number of concurrent streams it supports, but that number refers to the pushed streams that the server can send to the client.
Using the HTTP2Client
APIs you will have easy access to the stream id
and will be able to send to the server PRIORITY
frames to assign (and modify) priorities to requests.
This is a simple example of how to use HTTP2Client
.
You can find more examples in this directory.