Table of Contents
Headersanic.compatUpperStrEnumsanic.compatctrlc_workaround_for_windowssanic.compatenable_windows_color_supportsanic.compatopen_asyncsanic.compatpypy_os_module_patchsanic.compatpypy_windows_set_console_cp_patchsanic.compatuse_contextsanic.compatsanic.compat.Header#
Container used for both request and response headers.
class Header(self)
It is a subclass of CIMultiDict
It allows for multiple values for a single key in keeping with the HTTP spec. Also, all keys are case in-sensitive.
Please checkout the MultiDict documentation for more details about how to use the object. In general, it should work very similar to a regular dictionary.
sanic.compat.UpperStrEnum#
Base class for string enums that are case insensitive.
class UpperStrEnum(value, names = None, module = None, qualname = None, type = None, start = 1, boundary = None)
sanic.compat.ctrlc_workaround_for_windows#
def ctrlc_workaround_for_windows(app)
sanic.compat.enable_windows_color_support#
def enable_windows_color_support()
sanic.compat.open_async#
async def open_async(file, mode = r, kwargs)
sanic.compat.pypy_os_module_patch#
The PyPy os module is missing the 'readlink' function, which causes issues
def pypy_os_module_patch(): -> None
withaiofiles. This workaround replaces the missing 'readlink' function with 'os.path.realpath', which serves the same purpose.
sanic.compat.pypy_windows_set_console_cp_patch#
A patch function for PyPy on Windows that sets the console code page to
def pypy_windows_set_console_cp_patch(): -> None
UTF-8 encodingto allow for proper handling of non-ASCII characters. This function uses ctypes to call the Windows API functions SetConsoleCP and SetConsoleOutputCP to set the code page.
sanic.compat.use_context#
def use_context(method: typing.Union[sanic.helpers.Default, typing.Literal['fork'], typing.Literal['forkserver'], typing.Literal['spawn']])