Skip to content

Request

A request captured by the mock server — returned by Mock.received/Server.received_requests, and passed as the argument to a match:/respond: do |req| ... callback (see Server.mock).

Fields

method

The request method, e.g. "GET".

Type

Str

url

The full request URL.

Type

Str

headers

The request headers. Lazily projected from the underlying request — reading one header doesn't materialize the rest. Header names can repeat; .get() accepts an instance position to select among them (-1, the default, selects the last), matching dict.get.

Type

Dict-like

server.mock
  - match: do |req|
      req.headers["x-trace"] == "abc"
    respond:
      status: 200

body

The raw request body.

Type

Bin