No additional params are required, but you have to do them all in the same call, just like it’s documented.
Whether the requests will be performed concurrently is dependent on the server, i.e. HTTP/2 enabled servers can receive multiple requests at the same time, and HTTP/1.1 servers supporting pipeline as well.
Concurrency is therefore protocol-dependent, and httpx
will not maintain its own thread pool to enable this. If the server you’re requesting to doesn’t fit the criteria above, check Thread Safety.
No. httpx
handles the complexity for you, so you just need to assign HTTPX.plugin(:persistent)
to a variable, and this can be used in any context.
httpx
does maintain a per-thread connection pool however, meaning that, if you’re using multiple threads, connections to the same origin server will only be shared per-thread.
You can troubleshoot that by enabling the logs, where information of DNS requests, TLS handshake and connection state transitions will be displayed.
You must disable it in the ALPN negotiation:
HTTPX.with(ssl: { alpn_protocols: %w[http/1.1] }).get("https://example.com")
This library does HTTP only, and will not support other protocols. Ever. There is only one cURL :) .
Next: home