Override spray's default settings for sending requests with the given timeouts.
Override spray's default settings for sending requests with the given timeouts.
Note this automatically sets two different idle timeouts to be 2 * requestTimeout
:
format: OFF
HttpHostConnector
actors (internal to spray) without open
connections will automatically terminate themselves.
format: ONthe name of the remote host you want to communicate with
the port the remote host is listening on
the timeout to use when establishing a remote connection to the remote host
the timeout to use when waiting for a response from the remote host
the maximum number of connections to the remote host that will be held open at a time by the returned connector
an optional unique ID to use as the User-Agent header for requests to this host. If you want to maintain multiple host connector pools to a single remote host (for example, to prevent long-running requests from interfering with quick requests), setting this field to different values for each will prevent spray from sharing a connector between the different types of requests.
Send an HTTP request through spray using a dedicated HostConnectorSetup
, and process the
response using the given function.
Send an HTTP request through spray using a dedicated HostConnectorSetup
, and process the
response using the given function. This gives you much more control over how and when your
request is sent over the wire / when it times out than does use of sendReceive
.
Caveat: this function is designed to practically prevent you from needing to worry about
catching AskTimeoutExceptions
when using spray, but it's not actually possible to
guarantee. If you somehow send so many requests that one is internally buffered for more than
Int.MaxValue.millis
, you'll see an AskTimeoutException
thrown.
the HttpRequest
object to send over the wire
the HostConnectorSetup
object defining connection and timeout
information for your request. See getConnectionSetup
for a method of building these
connectors.
a function from HttpResponse
to a generic value T
you want to
extract from your request's response
Utility methods for sending HTTP requests through spray without being tripped-up by the nastiness of spray's API / underlying implementation. The two methods in this object are intended for use together.
Example: Making quick GET requests with little internal buffering. format: OFF
format: ON
Example: Making slow, CPU-intensive POST requests with internal rate-limiting. format: OFF
format: ON