An HTTP client for load tests.
{:ok, %{status: 200, body: body}} = Stampede.HTTP.get("http://localhost:4000/api/posts")
{:ok, %{status: 201}} = Stampede.HTTP.post("http://localhost:4000/api/posts", json: %{title: "Hi"})Responses are maps with the :status, the :headers, with lowercase
names, and the :body.
Each VU keeps a connection open to every server it talks to and sends its next request on it, as a browser does. When the server closed it in the meantime, a new one is opened, and a request that is safe to repeat (GET, HEAD, PUT, DELETE or OPTIONS) is sent again on it.
Metrics
Inside a run, requests record:
"http.request"- how long each response took, whatever its status"http.request.errors"- requests that failed, or whose response had a status of 400 or more
Summary
Types
@type response() :: %{ status: non_neg_integer(), headers: [{String.t(), String.t()}], body: binary() }
Functions
Sends a DELETE request. See request/3.
Sends a GET request. See request/3.
Sends a PATCH request. See request/3.
Sends a POST request. See request/3.
Sends a PUT request. See request/3.
Sends a method request to url and waits for the whole response.
Returns {:ok, response} whatever the status, and {:error, reason} when
there is no response, such as a Mint.TransportError.
Options
:headers- a list of{name, value}headers:body- the body, as iodata:json- a term to send as JSON instead of a:body, with acontent-typeofapplication/jsonunless one is given:timeout- how long to wait for the response, in milliseconds. Defaults to5_000.:metric- the timing to record the request as, ornilto record nothing. Defaults to"http.request".:transport_opts- options for:gen_tcpor:ssl, given toMint.HTTP.connect/4