sanic.helpers.Default#

It is used to replace None or object() as a sentinel

class Default()

that represents a default value. Sometimes we want to set a value to None so we cannot use None to represent the default value, and object() is hard to be typed.

sanic.helpers.has_message_body#

According to the following RFC message body and length SHOULD NOT

def has_message_body(status)

be included in responses status 1XX, 204 and 304. https://tools.ietf.org/html/rfc2616#section-4.4 https://tools.ietf.org/html/rfc2616#section-4.3

sanic.helpers.import_string#

import a module or class by string path.

def import_string(module_name, package = None)

sanic.helpers.is_atty#

def is_atty(): -> <class 'bool'>

sanic.helpers.is_entity_header#

Checks if the given header is an Entity Header

def is_entity_header(header)

sanic.helpers.is_hop_by_hop_header#

Checks if the given header is a Hop By Hop header

def is_hop_by_hop_header(header)

sanic.helpers.remove_entity_headers#

Removes all the entity headers present in the headers given.

def remove_entity_headers(headers, allowed = ('content-location', 'expires'))

According to RFC 2616 Section 10.3.5, Content-Location and Expires are allowed as for the "strong cache validator". https://tools.ietf.org/html/rfc2616#section-10.3.5

returns the headers without the entity headers