network.protocols.http.message - Palamecia/mint GitHub Wiki

Module

load network.protocols.http.message

This module provides the Network.Http.Message class which implement the structure of the messages used by Network.Http.Serializer.

Packages

Classes

Network.Http.Message

This class provides a structure for the messages used by Network.Http.Serializer and the Network.Http protocol. It provides helpers for reading and writing messages informations and for messages encoding de decoding.

Public members

Modifiers Member Description
@ const decode Creates an instance of Network.Http.Message from an instance of Serializer.Da...
const encode Returns the content of the message as an instance of Serializer.DataStream.
const getAttribute Returns the value of the attribute name of the header.
const getBody Returns the body of the message as a string.
const getMethod Returns the method of the message as a string.
const getStatusCode Returns the status code of the message as a number.
const getStatusText Returns the status message of the message as a string.
const getTarget Returns the target of the message as a string.
const new Creates a new empty message.
const setAttribute Sets the attribute name of the header to value.
const setBody Sets the body of the message to body. The Content-Length header will be a...
const setMethod Sets the method of the message to method on the givent target. The meth...
const setStatus Sets the status code of the message to code. If the message parameter is ...
const toString Returns the content of the message as a string.

Private members

Modifiers Member Description
final body Internal message body.
final code
final headers Internal header data.
final message
final method Internal method (request only).
final target Internal target (request only).
final version Internal protocol version.

Constants

Descriptions

Network.Http.Message.body

none

Internal message body.

Network.Http.Message.code

none

Network.Http.Message.decode

def (stream, length)

Creates an instance of Network.Http.Message from an instance of Serializer.DataStream given by stream. The length parameter is the number of bytes to be used to create the message.

Network.Http.Message.encode

def (self)

Returns the content of the message as an instance of Serializer.DataStream.

Network.Http.Message.getAttribute

def (const self, name)

Returns the value of the attribute name of the header.

Network.Http.Message.getBody

def (const self)

Returns the body of the message as a string.

Network.Http.Message.getMethod

def (const self)

Returns the method of the message as a string.

Network.Http.Message.getStatusCode

def (const self)

Returns the status code of the message as a number.

Network.Http.Message.getStatusText

def (const self)

Returns the status message of the message as a string.

Network.Http.Message.getTarget

def (const self)

Returns the target of the message as a string.

Network.Http.Message.headers

{}

Internal header data.

Network.Http.Message.message

none

Network.Http.Message.method

none

Internal method (request only).

Network.Http.Message.new

def (self)

Creates a new empty message.

def (self, identifier, complement = none)

Creates a new message described by identifier.

If identifier is an instance of Network.Http.Message, this instance is returned.

If identifier is a number, it is used as a status code to create a response message. The complement parameter can then provides a status message; otherwise the message will be guessed from the code.

If identifier is a number, it is used as an HTTP method to create a request message. The complement parameter can then provides a target URI.

Otherwise, the creation fails.

Network.Http.Message.setAttribute

def (self, name, value)

Sets the attribute name of the header to value.

Network.Http.Message.setBody

def (self, body, contentType = none)

Sets the body of the message to body. The Content-Length header will be automaticaly updated using the length of the body. If the contentType parameter is given, the value of the parameter will be used to setup the Content-Type header; otherwise the value will be guessed from the content of body.

Network.Http.Message.setMethod

def (self, method, target)

Sets the method of the message to method on the givent target.

The method paremeter should be one of 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE' or 'PATCH'.

Network.Http.Message.setStatus

def (self, code, message = none)

Sets the status code of the message to code. If the message parameter is given, the value of the parameter will be used as the status message; otherwise the message will be guessed from the status code.

Network.Http.Message.target

none

Internal target (request only).

Network.Http.Message.toString

def (const self)

Returns the content of the message as a string.

Network.Http.Message.version

'HTTP/1.0'

Internal protocol version.

Network.Http.Status

{100 : "Continue", 101 : "Switching Protocols", 103 : "Early Hints", 200 : "OK", 201 : "Created", 202 : "Accepted", 203 : "Non-Authoritative Information", 204 : "No Content", 205 : "Reset Content", 206 : "Partial Content", 300 : "Multiple Choices", 301 : "Moved Permanently", 302 : "Found", 303 : "See Other", 304 : "Not Modified", 307 : "Temporary Redirect", 308 : "Permanent Redirect", 400 : "Bad Request", 401 : "Unauthorized", 402 : "Payment Required", 403 : "Forbidden", 404 : "Not Found", 405 : "Method Not Allowed", 406 : "Not Acceptable", 407 : "Proxy Authentication Required", 408 : "Request Timeout", 409 : "Conflict", 410 : "Gone", 411 : "Length Required", 412 : "Precondition Failed", 413 : "Payload Too Large", 414 : "URI Too Long", 415 : "Unsupported Media Type", 416 : "Range Not Satisfiable", 417 : "Expectation Failed", 418 : "I'm a teapot", 422 : "Unprocessable Entity", 425 : "Too Early", 426 : "Upgrade Required", 428 : "Precondition Required", 429 : "Too Many Requests", 431 : "Request Header Fields Too Large", 451 : "Unavailable For Legal Reasons", 500 : "Internal Server Error", 501 : "Not Implemented", 502 : "Bad Gateway", 503 : "Service Unavailable", 504 : "Gateway Timeout", 505 : "HTTP Version Not Supported", 506 : "Variant Also Negotiates", 507 : "Insufficient Storage", 508 : "Loop Detected", 510 : "Not Extended", 511 : "Network Authentication Required"}

This hash provides the mapping between an HTTP status code and its message.