A request received over HTTP, is build by HttpRequestParser

Introduced properties

fun all_args: HashMap[String, String]

nitcorn :: HttpRequest :: all_args

The arguments passed with the POST or GET method (with a priority on POST)
protected fun all_args=(all_args: HashMap[String, String])

nitcorn :: HttpRequest :: all_args=

The arguments passed with the POST or GET method (with a priority on POST)
fun body: String

nitcorn :: HttpRequest :: body

The raw body of the request.
protected fun body=(body: String)

nitcorn :: HttpRequest :: body=

The raw body of the request.
fun bool_arg(arg_name: String): nullable Bool

nitcorn :: HttpRequest :: bool_arg

Returns argument arg_name as a Bool or null if not found or not a boolean.
fun clock: nullable Clock

nitcorn :: HttpRequest :: clock

Time that request was received by the Popcorn app.
protected fun clock=(clock: nullable Clock)

nitcorn :: HttpRequest :: clock=

Time that request was received by the Popcorn app.
fun cookie: HashMap[String, String]

nitcorn :: HttpRequest :: cookie

The content of the cookie of this request
protected fun cookie=(cookie: HashMap[String, String])

nitcorn :: HttpRequest :: cookie=

The content of the cookie of this request
fun get_args: HashMap[String, String]

nitcorn :: HttpRequest :: get_args

The arguments passed with the GET method,
protected fun get_args=(get_args: HashMap[String, String])

nitcorn :: HttpRequest :: get_args=

The arguments passed with the GET method,
fun header: HashMap[String, String]

nitcorn :: HttpRequest :: header

The header of this request
protected fun header=(header: HashMap[String, String])

nitcorn :: HttpRequest :: header=

The header of this request
fun http_version: String

nitcorn :: HttpRequest :: http_version

HTTP protocol version
protected fun http_version=(http_version: String)

nitcorn :: HttpRequest :: http_version=

HTTP protocol version
fun int_arg(arg_name: String): nullable Int

nitcorn :: HttpRequest :: int_arg

Returns argument arg_name as an Int or null if not found or not an integer.
fun method: String

nitcorn :: HttpRequest :: method

Method of this request (GET or POST)
protected fun method=(method: String)

nitcorn :: HttpRequest :: method=

Method of this request (GET or POST)
fun param(name: String): nullable String

nitcorn :: HttpRequest :: param

Get the value for parameter name or null.
fun params: Array[String]

nitcorn :: HttpRequest :: params

List all uri parameters matched by this request.
fun post_args: HashMap[String, String]

nitcorn :: HttpRequest :: post_args

The arguments passed with the POST method
protected fun post_args=(post_args: HashMap[String, String])

nitcorn :: HttpRequest :: post_args=

The arguments passed with the POST method
fun query_string: String

nitcorn :: HttpRequest :: query_string

The string following ? in the requested URL
protected fun query_string=(query_string: String)

nitcorn :: HttpRequest :: query_string=

The string following ? in the requested URL
fun session: nullable Session

nitcorn :: HttpRequest :: session

The Session associated to this request
fun session=(session: nullable Session)

nitcorn :: HttpRequest :: session=

The Session associated to this request
fun string_arg(arg_name: String): nullable String

nitcorn :: HttpRequest :: string_arg

Returns argument arg_name in the request as a String
fun timer: nullable Clock

nitcorn :: HttpRequest :: timer

Time that request was received by the Popcorn app.
protected fun timer=(timer: nullable Clock)

nitcorn :: HttpRequest :: timer=

Time that request was received by the Popcorn app.
fun uri: String

nitcorn :: HttpRequest :: uri

The resource requested by the client (only the page, not the query_string)
protected fun uri=(uri: String)

nitcorn :: HttpRequest :: uri=

The resource requested by the client (only the page, not the query_string)
fun uri_params: Map[String, String]

nitcorn :: HttpRequest :: uri_params

Parameters found in uri associated to their values.
fun uri_params=(uri_params: Map[String, String])

nitcorn :: HttpRequest :: uri_params=

Parameters found in uri associated to their values.
fun url: String

nitcorn :: HttpRequest :: url

The full URL requested by the client (including the query_string)
protected fun url=(url: String)

nitcorn :: HttpRequest :: url=

The full URL requested by the client (including the query_string)

Redefined properties

redef type SELF: HttpRequest

nitcorn $ HttpRequest :: SELF

Type of this instance, automatically specialized in every class
redef fun core_serialize_to(v: Serializer)

nitcorn $ HttpRequest :: core_serialize_to

Actual serialization of self to serializer
redef init from_deserializer(v: Deserializer)

nitcorn $ HttpRequest :: from_deserializer

Create an instance of this class from the deserializer

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
protected fun accept_json_serializer(v: JsonSerializer)

serialization :: Serializable :: accept_json_serializer

Refinable service to customize the serialization of this class to JSON
protected fun accept_msgpack_attribute_counter(v: AttributeCounter)

serialization :: Serializable :: accept_msgpack_attribute_counter

Hook to customize the behavior of the AttributeCounter
protected fun accept_msgpack_serializer(v: MsgPackSerializer)

serialization :: Serializable :: accept_msgpack_serializer

Hook to customize the serialization of this class to MessagePack
protected fun add_to_bundle(bundle: NativeBundle, key: JavaString)

serialization :: Serializable :: add_to_bundle

Called by []= to dynamically choose the appropriate method according
fun all_args: HashMap[String, String]

nitcorn :: HttpRequest :: all_args

The arguments passed with the POST or GET method (with a priority on POST)
protected fun all_args=(all_args: HashMap[String, String])

nitcorn :: HttpRequest :: all_args=

The arguments passed with the POST or GET method (with a priority on POST)
fun body: String

nitcorn :: HttpRequest :: body

The raw body of the request.
protected fun body=(body: String)

nitcorn :: HttpRequest :: body=

The raw body of the request.
fun bool_arg(arg_name: String): nullable Bool

nitcorn :: HttpRequest :: bool_arg

Returns argument arg_name as a Bool or null if not found or not a boolean.
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun clock: nullable Clock

nitcorn :: HttpRequest :: clock

Time that request was received by the Popcorn app.
protected fun clock=(clock: nullable Clock)

nitcorn :: HttpRequest :: clock=

Time that request was received by the Popcorn app.
fun cookie: HashMap[String, String]

nitcorn :: HttpRequest :: cookie

The content of the cookie of this request
protected fun cookie=(cookie: HashMap[String, String])

nitcorn :: HttpRequest :: cookie=

The content of the cookie of this request
fun core_serialize_to(serializer: Serializer)

serialization :: Serializable :: core_serialize_to

Actual serialization of self to serializer
init from_deserializer(deserializer: Deserializer)

serialization :: Serializable :: from_deserializer

Create an instance of this class from the deserializer
fun get_args: HashMap[String, String]

nitcorn :: HttpRequest :: get_args

The arguments passed with the GET method,
protected fun get_args=(get_args: HashMap[String, String])

nitcorn :: HttpRequest :: get_args=

The arguments passed with the GET method,
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun header: HashMap[String, String]

nitcorn :: HttpRequest :: header

The header of this request
protected fun header=(header: HashMap[String, String])

nitcorn :: HttpRequest :: header=

The header of this request
fun http_version: String

nitcorn :: HttpRequest :: http_version

HTTP protocol version
protected fun http_version=(http_version: String)

nitcorn :: HttpRequest :: http_version=

HTTP protocol version
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun int_arg(arg_name: String): nullable Int

nitcorn :: HttpRequest :: int_arg

Returns argument arg_name as an Int or null if not found or not an integer.
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun method: String

nitcorn :: HttpRequest :: method

Method of this request (GET or POST)
protected fun method=(method: String)

nitcorn :: HttpRequest :: method=

Method of this request (GET or POST)
protected fun msgpack_extra_array_items: Int

serialization :: Serializable :: msgpack_extra_array_items

Hook to request a larger than usual metadata array
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun param(name: String): nullable String

nitcorn :: HttpRequest :: param

Get the value for parameter name or null.
fun params: Array[String]

nitcorn :: HttpRequest :: params

List all uri parameters matched by this request.
fun post_args: HashMap[String, String]

nitcorn :: HttpRequest :: post_args

The arguments passed with the POST method
protected fun post_args=(post_args: HashMap[String, String])

nitcorn :: HttpRequest :: post_args=

The arguments passed with the POST method
fun query_string: String

nitcorn :: HttpRequest :: query_string

The string following ? in the requested URL
protected fun query_string=(query_string: String)

nitcorn :: HttpRequest :: query_string=

The string following ? in the requested URL
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun serialize_msgpack(plain: nullable Bool): Bytes

serialization :: Serializable :: serialize_msgpack

Serialize self to MessagePack bytes
fun serialize_to(serializer: Serializer)

serialization :: Serializable :: serialize_to

Serialize self to serializer
fun serialize_to_json(plain: nullable Bool, pretty: nullable Bool): String

serialization :: Serializable :: serialize_to_json

Serialize self to JSON
fun session: nullable Session

nitcorn :: HttpRequest :: session

The Session associated to this request
fun session=(session: nullable Session)

nitcorn :: HttpRequest :: session=

The Session associated to this request
fun string_arg(arg_name: String): nullable String

nitcorn :: HttpRequest :: string_arg

Returns argument arg_name in the request as a String
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun timer: nullable Clock

nitcorn :: HttpRequest :: timer

Time that request was received by the Popcorn app.
protected fun timer=(timer: nullable Clock)

nitcorn :: HttpRequest :: timer=

Time that request was received by the Popcorn app.
fun to_json: String

serialization :: Serializable :: to_json

Serialize self to plain JSON
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_pretty_json: String

serialization :: Serializable :: to_pretty_json

Serialize self to plain pretty JSON
fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun uri: String

nitcorn :: HttpRequest :: uri

The resource requested by the client (only the page, not the query_string)
protected fun uri=(uri: String)

nitcorn :: HttpRequest :: uri=

The resource requested by the client (only the page, not the query_string)
fun uri_params: Map[String, String]

nitcorn :: HttpRequest :: uri_params

Parameters found in uri associated to their values.
fun uri_params=(uri_params: Map[String, String])

nitcorn :: HttpRequest :: uri_params=

Parameters found in uri associated to their values.
fun url: String

nitcorn :: HttpRequest :: url

The full URL requested by the client (including the query_string)
protected fun url=(url: String)

nitcorn :: HttpRequest :: url=

The full URL requested by the client (including the query_string)
package_diagram nitcorn::HttpRequest HttpRequest serialization::Serializable Serializable nitcorn::HttpRequest->serialization::Serializable core::Object Object serialization::Serializable->core::Object ...core::Object ... ...core::Object->core::Object

Ancestors

interface Object

core :: Object

The root of the class hierarchy.

Parents

interface Serializable

serialization :: Serializable

Instances of this class can be passed to Serializer::serialize

Class definitions

nitcorn $ HttpRequest
# 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

nitcorn :: vararg_routes $ HttpRequest
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

nitcorn :: sessions $ HttpRequest
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

popcorn :: pop_logging $ HttpRequest
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

popcorn :: example_advanced_logger $ HttpRequest
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