class Marten::HTTP::Request
- Marten::HTTP::Request
- Reference
- Object
Overview
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.
Included Modules
Defined in:
marten/http/request.crmarten/spec/ext/marten/http/request.cr
marten/template/ext/marten/http/request.cr
Constructors
- .new(method : String, resource : String, headers : ::HTTP::Headers | Nil = nil, body : String | Bytes | IO | Nil = nil, version = "HTTP/1.1")
- .new(request : ::HTTP::Request)
Instance Method Summary
-
#accepted_media_types : Array(MIME::MediaType)
Returns an array of the media types accepted by the request.
-
#accepts?(media_type : String)
Returns
true
if the passed media type is accepted by the request. -
#body : String
Returns the raw body of the request as a string.
-
#content_security_policy : ContentSecurityPolicy | Nil
Returns the content security policy assigned with the request.
-
#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
). -
#content_security_policy_nonce
Returns the value of a Content-Security-Policy nonce associated with the request.
-
#cookies
Returns the cookies associated with the request.
-
#data : Params::Data
Returns the parsed request data.
-
#delete?
Returns
true
if the request is a DELETE. -
#flash
Returns the flash store for the considered request.
-
#flash=(flash_store : FlashStore)
Allows to set the flash store for the request.
-
#flash?
Returns
true
if the flash store was properly set for the considered request. -
#form_data?
Return
true
if the content type ismultipart/form-data
-
#full_path : String
Returns the path including the GET parameters if applicable.
-
#get?
Returns
true
if the request is a GET. -
#head?
Returns
true
if the request is a HEAD. -
#headers : Headers
Returns the HTTP headers embedded in the request.
-
#host : String
Returns the host associated with the considered request.
-
#method : String
Returns a string representation of HTTP method that was used in the request.
-
#options?
Returns
true
if the request is an OPTIONS. -
#patch?
Returns
true
if the request is a PATCH. -
#path : String
Returns the request path as a string.
-
#port : String | Nil
Returns the port associated with the considered request.
-
#post?
Returns
true
if the request is a POST. -
#put?
Returns
true
if the request is a PUT. -
#query_params : Params::Query
Returns the HTTP GET parameters embedded in the request.
-
#scheme : String
Returns the scheme of the request (either
"http"
or"https"
). -
#secure?
Returns
true
if the request is secure (if it is an HTTPS request). -
#session
Returns the session store for the considered request.
-
#session=(session_store : Session::Store::Base)
Allows to set the session store for the request.
-
#session?
Returns
true
if the session store was properly set for the considered request. -
#trace?
Returns
true
if the request is a TRACE. -
#urlencoded?
Returns
true
if the content type "application/x-www-form-urlencoded"
Macros inherited from module Marten::Template::CanDefineTemplateAttributes
template_attributes(*names)
template_attributes
Constructor Detail
Instance Method Detail
Returns an array of the media types accepted by the request.
Returns true
if the passed media type is accepted by the request.
Returns the content security policy assigned with the request.
Allows to assign a new content security policy to the request (or reset it if the passed value is nil
).
Returns the value of a Content-Security-Policy nonce associated with the request.
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.
Returns a string representation of HTTP method that was used in the request.
The returned method name (eg. "GET" or "POST") is completely uppercase.
Returns the request path as a string.
Only the path of the request is included (without scheme or domain).
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.
Allows to set the session store for the request.