class

Marten::HTTP::Request

Inherits Marten::Template::Object::Auto / Marten::Template::Object / Marten::Template::CanDefineTemplateAttributes / Reference / Object

Represents an HTTP request processed by Marten.

When a page is request, Marten creates a Marten::HTTP::Request that gives access to all the information and metadata of the incoming request.

Constructors

new(method : String, resource : String, headers : ::HTTP::Headers | Nil = nil, body : String | Bytes | IO | Nil = nil, version = "HTTP/1.1")
Source
new(request : ::HTTP::Request)
Source

Instance methods

accepted_media_types

Returns an array of the media types accepted by the request.

Source
accepts?(media_type : String)

Returns true if the passed media type is accepted by the request.

Source
body

Returns the raw body of the request as a string.

Source
content_security_policy

Returns the content security policy assigned with the request.

Source
content_security_policy=(content_security_policy : ContentSecurityPolicy | Nil)

Allows to assign a new content security policy to the request (or reset it if the passed value is nil).

Source
content_security_policy_nonce

Returns the value of a Content-Security-Policy nonce associated with the request.

Source
cookies

Returns the cookies associated with the request.

Source
data

Returns the parsed request data.

Source
delete?

Returns true if the request is a DELETE.

Source
flash

Returns the flash store for the considered request.

If no flash store was previously set (for example if the flash middleware is not used), a NilAssertionError exception will be raised.

Source
flash=(flash_store : FlashStore)

Allows to set the flash store for the request.

Source
flash?

Returns true if the flash store was properly set for the considered request.

Source
form_data?

Return true if the content type is multipart/form-data

Source
full_path

Returns the path including the GET parameters if applicable.

Source
get?

Returns true if the request is a GET.

Source
head?

Returns true if the request is a HEAD.

Source
headers

Returns the HTTP headers embedded in the request.

Source
host

Returns the host associated with the considered request.

Source
method

Returns a string representation of HTTP method that was used in the request.

The returned method name (eg. "GET" or "POST") is completely uppercase.

Source
options?

Returns true if the request is an OPTIONS.

Source
patch?

Returns true if the request is a PATCH.

Source
path

Returns the request path as a string.

Only the path of the request is included (without scheme or domain).

Source
port

Returns the port associated with the considered request.

Source
post?

Returns true if the request is a POST.

Source
put?

Returns true if the request is a PUT.

Source
query_params

Returns the HTTP GET parameters embedded in the request.

Source
scheme

Returns the scheme of the request (either "http" or "https").

Source
secure?

Returns true if the request is secure (if it is an HTTPS request).

Source
session

Returns the session store for the considered request.

If no session store was previously set (for example if the session middleware is not set), a NilAssertionError exception will be raised.

Source
session=(session_store : Session::Store::Base)

Allows to set the session store for the request.

Source
session?

Returns true if the session store was properly set for the considered request.

Source
trace?

Returns true if the request is a TRACE.

Source
urlencoded?

Returns true if the content type "application/x-www-form-urlencoded"

Source