HttpRequestParser
nitcorn :: HttpRequest :: clock
Time that request was received by the Popcorn app.nitcorn :: HttpRequest :: clock=
Time that request was received by the Popcorn app.nitcorn :: HttpRequest :: http_version=
HTTP protocol versionnitcorn :: HttpRequest :: method=
Method of this request (GET or POST)nitcorn :: HttpRequest :: post_args=
The arguments passed with the POST methodnitcorn :: HttpRequest :: query_string
The string following?
in the requested URL
nitcorn :: HttpRequest :: query_string=
The string following?
in the requested URL
nitcorn :: HttpRequest :: session
TheSession
associated to this request
nitcorn :: HttpRequest :: session=
TheSession
associated to this request
nitcorn :: HttpRequest :: string_arg
Returns argumentarg_name
in the request as a String
nitcorn :: HttpRequest :: timer
Time that request was received by the Popcorn app.nitcorn :: HttpRequest :: timer=
Time that request was received by the Popcorn app.nitcorn :: HttpRequest :: uri
The resource requested by the client (only the page, not thequery_string
)
nitcorn :: HttpRequest :: uri=
The resource requested by the client (only the page, not thequery_string
)
nitcorn :: HttpRequest :: uri_params
Parameters found in uri associated to their values.nitcorn :: HttpRequest :: uri_params=
Parameters found in uri associated to their values.nitcorn :: HttpRequest :: url
The full URL requested by the client (including thequery_string
)
nitcorn :: HttpRequest :: url=
The full URL requested by the client (including thequery_string
)
nitcorn $ HttpRequest :: SELF
Type of this instance, automatically specialized in every classnitcorn $ HttpRequest :: core_serialize_to
Actual serialization ofself
to serializer
nitcorn $ HttpRequest :: from_deserializer
Create an instance of this class from thedeserializer
serialization :: Serializable :: accept_json_serializer
Refinable service to customize the serialization of this class to JSONserialization :: Serializable :: accept_msgpack_attribute_counter
Hook to customize the behavior of theAttributeCounter
serialization :: Serializable :: accept_msgpack_serializer
Hook to customize the serialization of this class to MessagePackserialization :: Serializable :: add_to_bundle
Called by[]=
to dynamically choose the appropriate method according
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitcorn :: HttpRequest :: clock
Time that request was received by the Popcorn app.nitcorn :: HttpRequest :: clock=
Time that request was received by the Popcorn app.serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
core :: Object :: defaultinit
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
nitcorn :: HttpRequest :: http_version=
HTTP protocol versioncore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
nitcorn :: HttpRequest :: method=
Method of this request (GET or POST)serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: output_class_name
Display class name on stdout (debug only).nitcorn :: HttpRequest :: post_args=
The arguments passed with the POST methodnitcorn :: HttpRequest :: query_string
The string following?
in the requested URL
nitcorn :: HttpRequest :: query_string=
The string following?
in the requested URL
serialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
nitcorn :: HttpRequest :: session
TheSession
associated to this request
nitcorn :: HttpRequest :: session=
TheSession
associated to this request
nitcorn :: HttpRequest :: string_arg
Returns argumentarg_name
in the request as a String
nitcorn :: HttpRequest :: timer
Time that request was received by the Popcorn app.nitcorn :: HttpRequest :: timer=
Time that request was received by the Popcorn app.serialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
nitcorn :: HttpRequest :: uri
The resource requested by the client (only the page, not thequery_string
)
nitcorn :: HttpRequest :: uri=
The resource requested by the client (only the page, not thequery_string
)
nitcorn :: HttpRequest :: uri_params
Parameters found in uri associated to their values.nitcorn :: HttpRequest :: uri_params=
Parameters found in uri associated to their values.nitcorn :: HttpRequest :: url
The full URL requested by the client (including thequery_string
)
nitcorn :: HttpRequest :: url=
The full URL requested by the client (including thequery_string
)
Serializer::serialize
# A request received over HTTP, is build by `HttpRequestParser`
class HttpRequest
serialize
private init is old_style_init do end
# HTTP protocol version
var http_version: String
# Method of this request (GET or POST)
var method: String
# The full URL requested by the client (including the `query_string`)
var url: String
# The resource requested by the client (only the page, not the `query_string`)
var uri: String
# The string following `?` in the requested URL
var query_string = ""
# The header of this request
var header = new HashMap[String, String]
# The raw body of the request.
var body = ""
# The content of the cookie of this request
var cookie = new HashMap[String, String]
# The arguments passed with the GET method,
var get_args = new HashMap[String, String]
# The arguments passed with the POST method
var post_args = new HashMap[String, String]
# The arguments passed with the POST or GET method (with a priority on POST)
var all_args = new HashMap[String, String]
# Returns argument `arg_name` in the request as a String
# or null if it was not found.
# Also cleans the String by trimming it.
# If the Strings happens to be empty after trimming,
# the method will return `null`
#
# NOTE: Prioritizes POST before GET
fun string_arg(arg_name: String): nullable String do
if not all_args.has_key(arg_name) then return null
var s = all_args[arg_name].trim
if s.is_empty then return null
return s
end
# Returns argument `arg_name` as an Int or `null` if not found or not an integer.
#
# NOTE: Prioritizes POST before GET
fun int_arg(arg_name: String): nullable Int do
if not all_args.has_key(arg_name) then return null
var i = all_args[arg_name]
if not i.is_int then return null
return i.to_i
end
# Returns argument `arg_name` as a Bool or `null` if not found or not a boolean.
#
# NOTE: Prioritizes POST before GET
fun bool_arg(arg_name: String): nullable Bool do
if not all_args.has_key(arg_name) then return null
var i = all_args[arg_name]
if i == "true" then return true
if i == "false" then return false
return null
end
end
lib/nitcorn/http_request.nit:26,1--99,3
redef class HttpRequest
# Parameters found in uri associated to their values.
var uri_params: Map[String, String] = new HashMap[String, String] is public writable
# Get the value for parameter `name` or `null`.
fun param(name: String): nullable String do
if not uri_params.has_key(name) then return null
return uri_params[name]
end
# List all uri parameters matched by this request.
fun params: Array[String] do return uri_params.keys.to_a
end
lib/nitcorn/vararg_routes.nit:256,1--269,3
redef class HttpRequest
# The `Session` associated to this request
var session: nullable Session = null is writable
end
lib/nitcorn/sessions.nit:73,1--76,3
redef class HttpRequest
# Time that request was received by the Popcorn app.
var clock: nullable Clock = null
end
lib/popcorn/pop_logging.nit:98,1--101,3
redef class HttpRequest
# Time that request was received by the Popcorn app.
var timer: nullable Clock = null
end
lib/popcorn/examples/middlewares/example_advanced_logger.nit:22,1--25,3