id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26,700 | tornadoweb/tornado | tornado/web.py | stream_request_body | def stream_request_body(cls: Type[RequestHandler]) -> Type[RequestHandler]:
"""Apply to `RequestHandler` subclasses to enable streaming body support.
This decorator implies the following changes:
* `.HTTPServerRequest.body` is undefined, and body arguments will not
be included in `RequestHandler.get... | python | def stream_request_body(cls: Type[RequestHandler]) -> Type[RequestHandler]:
"""Apply to `RequestHandler` subclasses to enable streaming body support.
This decorator implies the following changes:
* `.HTTPServerRequest.body` is undefined, and body arguments will not
be included in `RequestHandler.get... | [
"def",
"stream_request_body",
"(",
"cls",
":",
"Type",
"[",
"RequestHandler",
"]",
")",
"->",
"Type",
"[",
"RequestHandler",
"]",
":",
"# noqa: E501",
"if",
"not",
"issubclass",
"(",
"cls",
",",
"RequestHandler",
")",
":",
"raise",
"TypeError",
"(",
"\"expec... | Apply to `RequestHandler` subclasses to enable streaming body support.
This decorator implies the following changes:
* `.HTTPServerRequest.body` is undefined, and body arguments will not
be included in `RequestHandler.get_argument`.
* `RequestHandler.prepare` is called when the request headers have ... | [
"Apply",
"to",
"RequestHandler",
"subclasses",
"to",
"enable",
"streaming",
"body",
"support",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1824-L1848 |
26,701 | tornadoweb/tornado | tornado/web.py | removeslash | def removeslash(
method: Callable[..., Optional[Awaitable[None]]]
) -> Callable[..., Optional[Awaitable[None]]]:
"""Use this decorator to remove trailing slashes from the request path.
For example, a request to ``/foo/`` would redirect to ``/foo`` with this
decorator. Your request handler mapping shoul... | python | def removeslash(
method: Callable[..., Optional[Awaitable[None]]]
) -> Callable[..., Optional[Awaitable[None]]]:
"""Use this decorator to remove trailing slashes from the request path.
For example, a request to ``/foo/`` would redirect to ``/foo`` with this
decorator. Your request handler mapping shoul... | [
"def",
"removeslash",
"(",
"method",
":",
"Callable",
"[",
"...",
",",
"Optional",
"[",
"Awaitable",
"[",
"None",
"]",
"]",
"]",
")",
"->",
"Callable",
"[",
"...",
",",
"Optional",
"[",
"Awaitable",
"[",
"None",
"]",
"]",
"]",
":",
"@",
"functools",
... | Use this decorator to remove trailing slashes from the request path.
For example, a request to ``/foo/`` would redirect to ``/foo`` with this
decorator. Your request handler mapping should use a regular expression
like ``r'/foo/*'`` in conjunction with using the decorator. | [
"Use",
"this",
"decorator",
"to",
"remove",
"trailing",
"slashes",
"from",
"the",
"request",
"path",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1857-L1883 |
26,702 | tornadoweb/tornado | tornado/web.py | authenticated | def authenticated(
method: Callable[..., Optional[Awaitable[None]]]
) -> Callable[..., Optional[Awaitable[None]]]:
"""Decorate methods with this to require that the user be logged in.
If the user is not logged in, they will be redirected to the configured
`login url <RequestHandler.get_login_url>`.
... | python | def authenticated(
method: Callable[..., Optional[Awaitable[None]]]
) -> Callable[..., Optional[Awaitable[None]]]:
"""Decorate methods with this to require that the user be logged in.
If the user is not logged in, they will be redirected to the configured
`login url <RequestHandler.get_login_url>`.
... | [
"def",
"authenticated",
"(",
"method",
":",
"Callable",
"[",
"...",
",",
"Optional",
"[",
"Awaitable",
"[",
"None",
"]",
"]",
"]",
")",
"->",
"Callable",
"[",
"...",
",",
"Optional",
"[",
"Awaitable",
"[",
"None",
"]",
"]",
"]",
":",
"@",
"functools"... | Decorate methods with this to require that the user be logged in.
If the user is not logged in, they will be redirected to the configured
`login url <RequestHandler.get_login_url>`.
If you configure a login url with a query parameter, Tornado will
assume you know what you're doing and use it as-is. I... | [
"Decorate",
"methods",
"with",
"this",
"to",
"require",
"that",
"the",
"user",
"be",
"logged",
"in",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L3142-L3176 |
26,703 | tornadoweb/tornado | tornado/web.py | RequestHandler.on_connection_close | def on_connection_close(self) -> None:
"""Called in async handlers if the client closed the connection.
Override this to clean up resources associated with
long-lived connections. Note that this method is called only if
the connection was closed during asynchronous processing; if you
... | python | def on_connection_close(self) -> None:
"""Called in async handlers if the client closed the connection.
Override this to clean up resources associated with
long-lived connections. Note that this method is called only if
the connection was closed during asynchronous processing; if you
... | [
"def",
"on_connection_close",
"(",
"self",
")",
"->",
"None",
":",
"if",
"_has_stream_request_body",
"(",
"self",
".",
"__class__",
")",
":",
"if",
"not",
"self",
".",
"request",
".",
"_body_future",
".",
"done",
"(",
")",
":",
"self",
".",
"request",
".... | Called in async handlers if the client closed the connection.
Override this to clean up resources associated with
long-lived connections. Note that this method is called only if
the connection was closed during asynchronous processing; if you
need to do cleanup after every request over... | [
"Called",
"in",
"async",
"handlers",
"if",
"the",
"client",
"closed",
"the",
"connection",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L300-L317 |
26,704 | tornadoweb/tornado | tornado/web.py | RequestHandler.clear | def clear(self) -> None:
"""Resets all headers and content for this response."""
self._headers = httputil.HTTPHeaders(
{
"Server": "TornadoServer/%s" % tornado.version,
"Content-Type": "text/html; charset=UTF-8",
"Date": httputil.format_timesta... | python | def clear(self) -> None:
"""Resets all headers and content for this response."""
self._headers = httputil.HTTPHeaders(
{
"Server": "TornadoServer/%s" % tornado.version,
"Content-Type": "text/html; charset=UTF-8",
"Date": httputil.format_timesta... | [
"def",
"clear",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_headers",
"=",
"httputil",
".",
"HTTPHeaders",
"(",
"{",
"\"Server\"",
":",
"\"TornadoServer/%s\"",
"%",
"tornado",
".",
"version",
",",
"\"Content-Type\"",
":",
"\"text/html; charset=UTF-8\"",
... | Resets all headers and content for this response. | [
"Resets",
"all",
"headers",
"and",
"content",
"for",
"this",
"response",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L319-L331 |
26,705 | tornadoweb/tornado | tornado/web.py | RequestHandler.set_status | def set_status(self, status_code: int, reason: str = None) -> None:
"""Sets the status code for our response.
:arg int status_code: Response status code.
:arg str reason: Human-readable reason phrase describing the status
code. If ``None``, it will be filled in from
`htt... | python | def set_status(self, status_code: int, reason: str = None) -> None:
"""Sets the status code for our response.
:arg int status_code: Response status code.
:arg str reason: Human-readable reason phrase describing the status
code. If ``None``, it will be filled in from
`htt... | [
"def",
"set_status",
"(",
"self",
",",
"status_code",
":",
"int",
",",
"reason",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"_status_code",
"=",
"status_code",
"if",
"reason",
"is",
"not",
"None",
":",
"self",
".",
"_reason",
"=",
... | Sets the status code for our response.
:arg int status_code: Response status code.
:arg str reason: Human-readable reason phrase describing the status
code. If ``None``, it will be filled in from
`http.client.responses` or "Unknown".
.. versionchanged:: 5.0
... | [
"Sets",
"the",
"status",
"code",
"for",
"our",
"response",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L343-L360 |
26,706 | tornadoweb/tornado | tornado/web.py | RequestHandler.set_header | def set_header(self, name: str, value: _HeaderTypes) -> None:
"""Sets the given response header name and value.
All header values are converted to strings (`datetime` objects
are formatted according to the HTTP specification for the
``Date`` header).
"""
self._headers[n... | python | def set_header(self, name: str, value: _HeaderTypes) -> None:
"""Sets the given response header name and value.
All header values are converted to strings (`datetime` objects
are formatted according to the HTTP specification for the
``Date`` header).
"""
self._headers[n... | [
"def",
"set_header",
"(",
"self",
",",
"name",
":",
"str",
",",
"value",
":",
"_HeaderTypes",
")",
"->",
"None",
":",
"self",
".",
"_headers",
"[",
"name",
"]",
"=",
"self",
".",
"_convert_header_value",
"(",
"value",
")"
] | Sets the given response header name and value.
All header values are converted to strings (`datetime` objects
are formatted according to the HTTP specification for the
``Date`` header). | [
"Sets",
"the",
"given",
"response",
"header",
"name",
"and",
"value",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L366-L374 |
26,707 | tornadoweb/tornado | tornado/web.py | RequestHandler.add_header | def add_header(self, name: str, value: _HeaderTypes) -> None:
"""Adds the given response header and value.
Unlike `set_header`, `add_header` may be called multiple times
to return multiple values for the same header.
"""
self._headers.add(name, self._convert_header_value(value)) | python | def add_header(self, name: str, value: _HeaderTypes) -> None:
"""Adds the given response header and value.
Unlike `set_header`, `add_header` may be called multiple times
to return multiple values for the same header.
"""
self._headers.add(name, self._convert_header_value(value)) | [
"def",
"add_header",
"(",
"self",
",",
"name",
":",
"str",
",",
"value",
":",
"_HeaderTypes",
")",
"->",
"None",
":",
"self",
".",
"_headers",
".",
"add",
"(",
"name",
",",
"self",
".",
"_convert_header_value",
"(",
"value",
")",
")"
] | Adds the given response header and value.
Unlike `set_header`, `add_header` may be called multiple times
to return multiple values for the same header. | [
"Adds",
"the",
"given",
"response",
"header",
"and",
"value",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L376-L382 |
26,708 | tornadoweb/tornado | tornado/web.py | RequestHandler.clear_header | def clear_header(self, name: str) -> None:
"""Clears an outgoing header, undoing a previous `set_header` call.
Note that this method does not apply to multi-valued headers
set by `add_header`.
"""
if name in self._headers:
del self._headers[name] | python | def clear_header(self, name: str) -> None:
"""Clears an outgoing header, undoing a previous `set_header` call.
Note that this method does not apply to multi-valued headers
set by `add_header`.
"""
if name in self._headers:
del self._headers[name] | [
"def",
"clear_header",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"None",
":",
"if",
"name",
"in",
"self",
".",
"_headers",
":",
"del",
"self",
".",
"_headers",
"[",
"name",
"]"
] | Clears an outgoing header, undoing a previous `set_header` call.
Note that this method does not apply to multi-valued headers
set by `add_header`. | [
"Clears",
"an",
"outgoing",
"header",
"undoing",
"a",
"previous",
"set_header",
"call",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L384-L391 |
26,709 | tornadoweb/tornado | tornado/web.py | RequestHandler.get_arguments | def get_arguments(self, name: str, strip: bool = True) -> List[str]:
"""Returns a list of the arguments with the given name.
If the argument is not present, returns an empty list.
This method searches both the query and body arguments.
"""
# Make sure `get_arguments` isn't acc... | python | def get_arguments(self, name: str, strip: bool = True) -> List[str]:
"""Returns a list of the arguments with the given name.
If the argument is not present, returns an empty list.
This method searches both the query and body arguments.
"""
# Make sure `get_arguments` isn't acc... | [
"def",
"get_arguments",
"(",
"self",
",",
"name",
":",
"str",
",",
"strip",
":",
"bool",
"=",
"True",
")",
"->",
"List",
"[",
"str",
"]",
":",
"# Make sure `get_arguments` isn't accidentally being called with a",
"# positional argument that's assumed to be a default (like... | Returns a list of the arguments with the given name.
If the argument is not present, returns an empty list.
This method searches both the query and body arguments. | [
"Returns",
"a",
"list",
"of",
"the",
"arguments",
"with",
"the",
"given",
"name",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L457-L470 |
26,710 | tornadoweb/tornado | tornado/web.py | RequestHandler.get_body_argument | def get_body_argument(
self,
name: str,
default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT,
strip: bool = True,
) -> Optional[str]:
"""Returns the value of the argument with the given name
from the request body.
If default is not provided, the argume... | python | def get_body_argument(
self,
name: str,
default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT,
strip: bool = True,
) -> Optional[str]:
"""Returns the value of the argument with the given name
from the request body.
If default is not provided, the argume... | [
"def",
"get_body_argument",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
":",
"Union",
"[",
"None",
",",
"str",
",",
"_ArgDefaultMarker",
"]",
"=",
"_ARG_DEFAULT",
",",
"strip",
":",
"bool",
"=",
"True",
",",
")",
"->",
"Optional",
"[",
"str",... | Returns the value of the argument with the given name
from the request body.
If default is not provided, the argument is considered to be
required, and we raise a `MissingArgumentError` if it is missing.
If the argument appears in the url more than once, we return the
last valu... | [
"Returns",
"the",
"value",
"of",
"the",
"argument",
"with",
"the",
"given",
"name",
"from",
"the",
"request",
"body",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L472-L489 |
26,711 | tornadoweb/tornado | tornado/web.py | RequestHandler.get_body_arguments | def get_body_arguments(self, name: str, strip: bool = True) -> List[str]:
"""Returns a list of the body arguments with the given name.
If the argument is not present, returns an empty list.
.. versionadded:: 3.2
"""
return self._get_arguments(name, self.request.body_arguments, ... | python | def get_body_arguments(self, name: str, strip: bool = True) -> List[str]:
"""Returns a list of the body arguments with the given name.
If the argument is not present, returns an empty list.
.. versionadded:: 3.2
"""
return self._get_arguments(name, self.request.body_arguments, ... | [
"def",
"get_body_arguments",
"(",
"self",
",",
"name",
":",
"str",
",",
"strip",
":",
"bool",
"=",
"True",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_get_arguments",
"(",
"name",
",",
"self",
".",
"request",
".",
"body_arguments"... | Returns a list of the body arguments with the given name.
If the argument is not present, returns an empty list.
.. versionadded:: 3.2 | [
"Returns",
"a",
"list",
"of",
"the",
"body",
"arguments",
"with",
"the",
"given",
"name",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L491-L498 |
26,712 | tornadoweb/tornado | tornado/web.py | RequestHandler.get_query_argument | def get_query_argument(
self,
name: str,
default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT,
strip: bool = True,
) -> Optional[str]:
"""Returns the value of the argument with the given name
from the request query string.
If default is not provided, t... | python | def get_query_argument(
self,
name: str,
default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT,
strip: bool = True,
) -> Optional[str]:
"""Returns the value of the argument with the given name
from the request query string.
If default is not provided, t... | [
"def",
"get_query_argument",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
":",
"Union",
"[",
"None",
",",
"str",
",",
"_ArgDefaultMarker",
"]",
"=",
"_ARG_DEFAULT",
",",
"strip",
":",
"bool",
"=",
"True",
",",
")",
"->",
"Optional",
"[",
"str"... | Returns the value of the argument with the given name
from the request query string.
If default is not provided, the argument is considered to be
required, and we raise a `MissingArgumentError` if it is missing.
If the argument appears in the url more than once, we return the
l... | [
"Returns",
"the",
"value",
"of",
"the",
"argument",
"with",
"the",
"given",
"name",
"from",
"the",
"request",
"query",
"string",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L500-L517 |
26,713 | tornadoweb/tornado | tornado/web.py | RequestHandler.get_query_arguments | def get_query_arguments(self, name: str, strip: bool = True) -> List[str]:
"""Returns a list of the query arguments with the given name.
If the argument is not present, returns an empty list.
.. versionadded:: 3.2
"""
return self._get_arguments(name, self.request.query_argument... | python | def get_query_arguments(self, name: str, strip: bool = True) -> List[str]:
"""Returns a list of the query arguments with the given name.
If the argument is not present, returns an empty list.
.. versionadded:: 3.2
"""
return self._get_arguments(name, self.request.query_argument... | [
"def",
"get_query_arguments",
"(",
"self",
",",
"name",
":",
"str",
",",
"strip",
":",
"bool",
"=",
"True",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_get_arguments",
"(",
"name",
",",
"self",
".",
"request",
".",
"query_argument... | Returns a list of the query arguments with the given name.
If the argument is not present, returns an empty list.
.. versionadded:: 3.2 | [
"Returns",
"a",
"list",
"of",
"the",
"query",
"arguments",
"with",
"the",
"given",
"name",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L519-L526 |
26,714 | tornadoweb/tornado | tornado/web.py | RequestHandler.decode_argument | def decode_argument(self, value: bytes, name: str = None) -> str:
"""Decodes an argument from the request.
The argument has been percent-decoded and is now a byte string.
By default, this method decodes the argument as utf-8 and returns
a unicode string, but this may be overridden in su... | python | def decode_argument(self, value: bytes, name: str = None) -> str:
"""Decodes an argument from the request.
The argument has been percent-decoded and is now a byte string.
By default, this method decodes the argument as utf-8 and returns
a unicode string, but this may be overridden in su... | [
"def",
"decode_argument",
"(",
"self",
",",
"value",
":",
"bytes",
",",
"name",
":",
"str",
"=",
"None",
")",
"->",
"str",
":",
"try",
":",
"return",
"_unicode",
"(",
"value",
")",
"except",
"UnicodeDecodeError",
":",
"raise",
"HTTPError",
"(",
"400",
... | Decodes an argument from the request.
The argument has been percent-decoded and is now a byte string.
By default, this method decodes the argument as utf-8 and returns
a unicode string, but this may be overridden in subclasses.
This method is used as a filter for both `get_argument()` ... | [
"Decodes",
"an",
"argument",
"from",
"the",
"request",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L557-L575 |
26,715 | tornadoweb/tornado | tornado/web.py | RequestHandler.get_cookie | def get_cookie(self, name: str, default: str = None) -> Optional[str]:
"""Returns the value of the request cookie with the given name.
If the named cookie is not present, returns ``default``.
This method only returns cookies that were present in the request.
It does not see the outgoin... | python | def get_cookie(self, name: str, default: str = None) -> Optional[str]:
"""Returns the value of the request cookie with the given name.
If the named cookie is not present, returns ``default``.
This method only returns cookies that were present in the request.
It does not see the outgoin... | [
"def",
"get_cookie",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
":",
"str",
"=",
"None",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"self",
".",
"request",
".",
"cookies",
"is",
"not",
"None",
"and",
"name",
"in",
"self",
".",
... | Returns the value of the request cookie with the given name.
If the named cookie is not present, returns ``default``.
This method only returns cookies that were present in the request.
It does not see the outgoing cookies set by `set_cookie` in this
handler. | [
"Returns",
"the",
"value",
"of",
"the",
"request",
"cookie",
"with",
"the",
"given",
"name",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L583-L594 |
26,716 | tornadoweb/tornado | tornado/web.py | RequestHandler.clear_cookie | def clear_cookie(self, name: str, path: str = "/", domain: str = None) -> None:
"""Deletes the cookie with the given name.
Due to limitations of the cookie protocol, you must pass the same
path and domain to clear a cookie as were used when that cookie
was set (but there is no way to fi... | python | def clear_cookie(self, name: str, path: str = "/", domain: str = None) -> None:
"""Deletes the cookie with the given name.
Due to limitations of the cookie protocol, you must pass the same
path and domain to clear a cookie as were used when that cookie
was set (but there is no way to fi... | [
"def",
"clear_cookie",
"(",
"self",
",",
"name",
":",
"str",
",",
"path",
":",
"str",
"=",
"\"/\"",
",",
"domain",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"expires",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"-",
"datetime... | Deletes the cookie with the given name.
Due to limitations of the cookie protocol, you must pass the same
path and domain to clear a cookie as were used when that cookie
was set (but there is no way to find out on the server side
which values were used for a given cookie).
Simi... | [
"Deletes",
"the",
"cookie",
"with",
"the",
"given",
"name",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L651-L663 |
26,717 | tornadoweb/tornado | tornado/web.py | RequestHandler.clear_all_cookies | def clear_all_cookies(self, path: str = "/", domain: str = None) -> None:
"""Deletes all the cookies the user sent with this request.
See `clear_cookie` for more information on the path and domain
parameters.
Similar to `set_cookie`, the effect of this method will not be
seen u... | python | def clear_all_cookies(self, path: str = "/", domain: str = None) -> None:
"""Deletes all the cookies the user sent with this request.
See `clear_cookie` for more information on the path and domain
parameters.
Similar to `set_cookie`, the effect of this method will not be
seen u... | [
"def",
"clear_all_cookies",
"(",
"self",
",",
"path",
":",
"str",
"=",
"\"/\"",
",",
"domain",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"for",
"name",
"in",
"self",
".",
"request",
".",
"cookies",
":",
"self",
".",
"clear_cookie",
"(",
"name"... | Deletes all the cookies the user sent with this request.
See `clear_cookie` for more information on the path and domain
parameters.
Similar to `set_cookie`, the effect of this method will not be
seen until the following request.
.. versionchanged:: 3.2
Added the ``... | [
"Deletes",
"all",
"the",
"cookies",
"the",
"user",
"sent",
"with",
"this",
"request",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L665-L679 |
26,718 | tornadoweb/tornado | tornado/web.py | RequestHandler.set_secure_cookie | def set_secure_cookie(
self,
name: str,
value: Union[str, bytes],
expires_days: int = 30,
version: int = None,
**kwargs: Any
) -> None:
"""Signs and timestamps a cookie so it cannot be forged.
You must specify the ``cookie_secret`` setting in your App... | python | def set_secure_cookie(
self,
name: str,
value: Union[str, bytes],
expires_days: int = 30,
version: int = None,
**kwargs: Any
) -> None:
"""Signs and timestamps a cookie so it cannot be forged.
You must specify the ``cookie_secret`` setting in your App... | [
"def",
"set_secure_cookie",
"(",
"self",
",",
"name",
":",
"str",
",",
"value",
":",
"Union",
"[",
"str",
",",
"bytes",
"]",
",",
"expires_days",
":",
"int",
"=",
"30",
",",
"version",
":",
"int",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
... | Signs and timestamps a cookie so it cannot be forged.
You must specify the ``cookie_secret`` setting in your Application
to use this method. It should be a long, random sequence of bytes
to be used as the HMAC secret for the signature.
To read a cookie set with this method, use `get_se... | [
"Signs",
"and",
"timestamps",
"a",
"cookie",
"so",
"it",
"cannot",
"be",
"forged",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L681-L717 |
26,719 | tornadoweb/tornado | tornado/web.py | RequestHandler.create_signed_value | def create_signed_value(
self, name: str, value: Union[str, bytes], version: int = None
) -> bytes:
"""Signs and timestamps a string so it cannot be forged.
Normally used via set_secure_cookie, but provided as a separate
method for non-cookie uses. To decode a value not stored
... | python | def create_signed_value(
self, name: str, value: Union[str, bytes], version: int = None
) -> bytes:
"""Signs and timestamps a string so it cannot be forged.
Normally used via set_secure_cookie, but provided as a separate
method for non-cookie uses. To decode a value not stored
... | [
"def",
"create_signed_value",
"(",
"self",
",",
"name",
":",
"str",
",",
"value",
":",
"Union",
"[",
"str",
",",
"bytes",
"]",
",",
"version",
":",
"int",
"=",
"None",
")",
"->",
"bytes",
":",
"self",
".",
"require_setting",
"(",
"\"cookie_secret\"",
"... | Signs and timestamps a string so it cannot be forged.
Normally used via set_secure_cookie, but provided as a separate
method for non-cookie uses. To decode a value not stored
as a cookie use the optional value argument to get_secure_cookie.
.. versionchanged:: 3.2.1
Added ... | [
"Signs",
"and",
"timestamps",
"a",
"string",
"so",
"it",
"cannot",
"be",
"forged",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L719-L743 |
26,720 | tornadoweb/tornado | tornado/web.py | RequestHandler.get_secure_cookie | def get_secure_cookie(
self,
name: str,
value: str = None,
max_age_days: int = 31,
min_version: int = None,
) -> Optional[bytes]:
"""Returns the given signed cookie if it validates, or None.
The decoded cookie value is returned as a byte string (unlike
... | python | def get_secure_cookie(
self,
name: str,
value: str = None,
max_age_days: int = 31,
min_version: int = None,
) -> Optional[bytes]:
"""Returns the given signed cookie if it validates, or None.
The decoded cookie value is returned as a byte string (unlike
... | [
"def",
"get_secure_cookie",
"(",
"self",
",",
"name",
":",
"str",
",",
"value",
":",
"str",
"=",
"None",
",",
"max_age_days",
":",
"int",
"=",
"31",
",",
"min_version",
":",
"int",
"=",
"None",
",",
")",
"->",
"Optional",
"[",
"bytes",
"]",
":",
"s... | Returns the given signed cookie if it validates, or None.
The decoded cookie value is returned as a byte string (unlike
`get_cookie`).
Similar to `get_cookie`, this method only returns cookies that
were present in the request. It does not see outgoing cookies set by
`set_secure... | [
"Returns",
"the",
"given",
"signed",
"cookie",
"if",
"it",
"validates",
"or",
"None",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L745-L775 |
26,721 | tornadoweb/tornado | tornado/web.py | RequestHandler.get_secure_cookie_key_version | def get_secure_cookie_key_version(
self, name: str, value: str = None
) -> Optional[int]:
"""Returns the signing key version of the secure cookie.
The version is returned as int.
"""
self.require_setting("cookie_secret", "secure cookies")
if value is None:
... | python | def get_secure_cookie_key_version(
self, name: str, value: str = None
) -> Optional[int]:
"""Returns the signing key version of the secure cookie.
The version is returned as int.
"""
self.require_setting("cookie_secret", "secure cookies")
if value is None:
... | [
"def",
"get_secure_cookie_key_version",
"(",
"self",
",",
"name",
":",
"str",
",",
"value",
":",
"str",
"=",
"None",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"self",
".",
"require_setting",
"(",
"\"cookie_secret\"",
",",
"\"secure cookies\"",
")",
"if",
... | Returns the signing key version of the secure cookie.
The version is returned as int. | [
"Returns",
"the",
"signing",
"key",
"version",
"of",
"the",
"secure",
"cookie",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L777-L789 |
26,722 | tornadoweb/tornado | tornado/web.py | RequestHandler.write | def write(self, chunk: Union[str, bytes, dict]) -> None:
"""Writes the given chunk to the output buffer.
To write the output to the network, use the `flush()` method below.
If the given chunk is a dictionary, we write it as JSON and set
the Content-Type of the response to be ``applicat... | python | def write(self, chunk: Union[str, bytes, dict]) -> None:
"""Writes the given chunk to the output buffer.
To write the output to the network, use the `flush()` method below.
If the given chunk is a dictionary, we write it as JSON and set
the Content-Type of the response to be ``applicat... | [
"def",
"write",
"(",
"self",
",",
"chunk",
":",
"Union",
"[",
"str",
",",
"bytes",
",",
"dict",
"]",
")",
"->",
"None",
":",
"if",
"self",
".",
"_finished",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot write() after finish()\"",
")",
"if",
"not",
"isinst... | Writes the given chunk to the output buffer.
To write the output to the network, use the `flush()` method below.
If the given chunk is a dictionary, we write it as JSON and set
the Content-Type of the response to be ``application/json``.
(if you want to send JSON as a different ``Conte... | [
"Writes",
"the",
"given",
"chunk",
"to",
"the",
"output",
"buffer",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L809-L839 |
26,723 | tornadoweb/tornado | tornado/web.py | RequestHandler.render | def render(self, template_name: str, **kwargs: Any) -> "Future[None]":
"""Renders the template with the given arguments as the response.
``render()`` calls ``finish()``, so no other output methods can be called
after it.
Returns a `.Future` with the same semantics as the one returned b... | python | def render(self, template_name: str, **kwargs: Any) -> "Future[None]":
"""Renders the template with the given arguments as the response.
``render()`` calls ``finish()``, so no other output methods can be called
after it.
Returns a `.Future` with the same semantics as the one returned b... | [
"def",
"render",
"(",
"self",
",",
"template_name",
":",
"str",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"\"Future[None]\"",
":",
"if",
"self",
".",
"_finished",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot render() after finish()\"",
")",
"html",
"="... | Renders the template with the given arguments as the response.
``render()`` calls ``finish()``, so no other output methods can be called
after it.
Returns a `.Future` with the same semantics as the one returned by `finish`.
Awaiting this `.Future` is optional.
.. versionchange... | [
"Renders",
"the",
"template",
"with",
"the",
"given",
"arguments",
"as",
"the",
"response",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L841-L914 |
26,724 | tornadoweb/tornado | tornado/web.py | RequestHandler.render_linked_js | def render_linked_js(self, js_files: Iterable[str]) -> str:
"""Default method used to render the final js links for the
rendered webpage.
Override this method in a sub-classed controller to change the output.
"""
paths = []
unique_paths = set() # type: Set[str]
... | python | def render_linked_js(self, js_files: Iterable[str]) -> str:
"""Default method used to render the final js links for the
rendered webpage.
Override this method in a sub-classed controller to change the output.
"""
paths = []
unique_paths = set() # type: Set[str]
... | [
"def",
"render_linked_js",
"(",
"self",
",",
"js_files",
":",
"Iterable",
"[",
"str",
"]",
")",
"->",
"str",
":",
"paths",
"=",
"[",
"]",
"unique_paths",
"=",
"set",
"(",
")",
"# type: Set[str]",
"for",
"path",
"in",
"js_files",
":",
"if",
"not",
"is_a... | Default method used to render the final js links for the
rendered webpage.
Override this method in a sub-classed controller to change the output. | [
"Default",
"method",
"used",
"to",
"render",
"the",
"final",
"js",
"links",
"for",
"the",
"rendered",
"webpage",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L916-L937 |
26,725 | tornadoweb/tornado | tornado/web.py | RequestHandler.render_embed_js | def render_embed_js(self, js_embed: Iterable[bytes]) -> bytes:
"""Default method used to render the final embedded js for the
rendered webpage.
Override this method in a sub-classed controller to change the output.
"""
return (
b'<script type="text/javascript">\n//<!... | python | def render_embed_js(self, js_embed: Iterable[bytes]) -> bytes:
"""Default method used to render the final embedded js for the
rendered webpage.
Override this method in a sub-classed controller to change the output.
"""
return (
b'<script type="text/javascript">\n//<!... | [
"def",
"render_embed_js",
"(",
"self",
",",
"js_embed",
":",
"Iterable",
"[",
"bytes",
"]",
")",
"->",
"bytes",
":",
"return",
"(",
"b'<script type=\"text/javascript\">\\n//<![CDATA[\\n'",
"+",
"b\"\\n\"",
".",
"join",
"(",
"js_embed",
")",
"+",
"b\"\\n//]]>\\n</s... | Default method used to render the final embedded js for the
rendered webpage.
Override this method in a sub-classed controller to change the output. | [
"Default",
"method",
"used",
"to",
"render",
"the",
"final",
"embedded",
"js",
"for",
"the",
"rendered",
"webpage",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L939-L949 |
26,726 | tornadoweb/tornado | tornado/web.py | RequestHandler.render_linked_css | def render_linked_css(self, css_files: Iterable[str]) -> str:
"""Default method used to render the final css links for the
rendered webpage.
Override this method in a sub-classed controller to change the output.
"""
paths = []
unique_paths = set() # type: Set[str]
... | python | def render_linked_css(self, css_files: Iterable[str]) -> str:
"""Default method used to render the final css links for the
rendered webpage.
Override this method in a sub-classed controller to change the output.
"""
paths = []
unique_paths = set() # type: Set[str]
... | [
"def",
"render_linked_css",
"(",
"self",
",",
"css_files",
":",
"Iterable",
"[",
"str",
"]",
")",
"->",
"str",
":",
"paths",
"=",
"[",
"]",
"unique_paths",
"=",
"set",
"(",
")",
"# type: Set[str]",
"for",
"path",
"in",
"css_files",
":",
"if",
"not",
"i... | Default method used to render the final css links for the
rendered webpage.
Override this method in a sub-classed controller to change the output. | [
"Default",
"method",
"used",
"to",
"render",
"the",
"final",
"css",
"links",
"for",
"the",
"rendered",
"webpage",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L951-L971 |
26,727 | tornadoweb/tornado | tornado/web.py | RequestHandler.render_embed_css | def render_embed_css(self, css_embed: Iterable[bytes]) -> bytes:
"""Default method used to render the final embedded css for the
rendered webpage.
Override this method in a sub-classed controller to change the output.
"""
return b'<style type="text/css">\n' + b"\n".join(css_embe... | python | def render_embed_css(self, css_embed: Iterable[bytes]) -> bytes:
"""Default method used to render the final embedded css for the
rendered webpage.
Override this method in a sub-classed controller to change the output.
"""
return b'<style type="text/css">\n' + b"\n".join(css_embe... | [
"def",
"render_embed_css",
"(",
"self",
",",
"css_embed",
":",
"Iterable",
"[",
"bytes",
"]",
")",
"->",
"bytes",
":",
"return",
"b'<style type=\"text/css\">\\n'",
"+",
"b\"\\n\"",
".",
"join",
"(",
"css_embed",
")",
"+",
"b\"\\n</style>\""
] | Default method used to render the final embedded css for the
rendered webpage.
Override this method in a sub-classed controller to change the output. | [
"Default",
"method",
"used",
"to",
"render",
"the",
"final",
"embedded",
"css",
"for",
"the",
"rendered",
"webpage",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L973-L979 |
26,728 | tornadoweb/tornado | tornado/web.py | RequestHandler.render_string | def render_string(self, template_name: str, **kwargs: Any) -> bytes:
"""Generate the given template with the given arguments.
We return the generated byte string (in utf8). To generate and
write a template as a response, use render() above.
"""
# If no template_path is specified... | python | def render_string(self, template_name: str, **kwargs: Any) -> bytes:
"""Generate the given template with the given arguments.
We return the generated byte string (in utf8). To generate and
write a template as a response, use render() above.
"""
# If no template_path is specified... | [
"def",
"render_string",
"(",
"self",
",",
"template_name",
":",
"str",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"bytes",
":",
"# If no template_path is specified, use the path of the calling file",
"template_path",
"=",
"self",
".",
"get_template_path",
"(",
... | Generate the given template with the given arguments.
We return the generated byte string (in utf8). To generate and
write a template as a response, use render() above. | [
"Generate",
"the",
"given",
"template",
"with",
"the",
"given",
"arguments",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L981-L1005 |
26,729 | tornadoweb/tornado | tornado/web.py | RequestHandler.get_template_namespace | def get_template_namespace(self) -> Dict[str, Any]:
"""Returns a dictionary to be used as the default template namespace.
May be overridden by subclasses to add or modify values.
The results of this method will be combined with additional
defaults in the `tornado.template` module and k... | python | def get_template_namespace(self) -> Dict[str, Any]:
"""Returns a dictionary to be used as the default template namespace.
May be overridden by subclasses to add or modify values.
The results of this method will be combined with additional
defaults in the `tornado.template` module and k... | [
"def",
"get_template_namespace",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"namespace",
"=",
"dict",
"(",
"handler",
"=",
"self",
",",
"request",
"=",
"self",
".",
"request",
",",
"current_user",
"=",
"self",
".",
"current_user",
... | Returns a dictionary to be used as the default template namespace.
May be overridden by subclasses to add or modify values.
The results of this method will be combined with additional
defaults in the `tornado.template` module and keyword arguments
to `render` or `render_string`. | [
"Returns",
"a",
"dictionary",
"to",
"be",
"used",
"as",
"the",
"default",
"template",
"namespace",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1007-L1028 |
26,730 | tornadoweb/tornado | tornado/web.py | RequestHandler.create_template_loader | def create_template_loader(self, template_path: str) -> template.BaseLoader:
"""Returns a new template loader for the given path.
May be overridden by subclasses. By default returns a
directory-based loader on the given path, using the
``autoescape`` and ``template_whitespace`` applica... | python | def create_template_loader(self, template_path: str) -> template.BaseLoader:
"""Returns a new template loader for the given path.
May be overridden by subclasses. By default returns a
directory-based loader on the given path, using the
``autoescape`` and ``template_whitespace`` applica... | [
"def",
"create_template_loader",
"(",
"self",
",",
"template_path",
":",
"str",
")",
"->",
"template",
".",
"BaseLoader",
":",
"settings",
"=",
"self",
".",
"application",
".",
"settings",
"if",
"\"template_loader\"",
"in",
"settings",
":",
"return",
"settings",... | Returns a new template loader for the given path.
May be overridden by subclasses. By default returns a
directory-based loader on the given path, using the
``autoescape`` and ``template_whitespace`` application
settings. If a ``template_loader`` application setting is
supplied... | [
"Returns",
"a",
"new",
"template",
"loader",
"for",
"the",
"given",
"path",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1030-L1049 |
26,731 | tornadoweb/tornado | tornado/web.py | RequestHandler.flush | def flush(self, include_footers: bool = False) -> "Future[None]":
"""Flushes the current output buffer to the network.
The ``callback`` argument, if given, can be used for flow control:
it will be run when all flushed data has been written to the socket.
Note that only one flush callbac... | python | def flush(self, include_footers: bool = False) -> "Future[None]":
"""Flushes the current output buffer to the network.
The ``callback`` argument, if given, can be used for flow control:
it will be run when all flushed data has been written to the socket.
Note that only one flush callbac... | [
"def",
"flush",
"(",
"self",
",",
"include_footers",
":",
"bool",
"=",
"False",
")",
"->",
"\"Future[None]\"",
":",
"assert",
"self",
".",
"request",
".",
"connection",
"is",
"not",
"None",
"chunk",
"=",
"b\"\"",
".",
"join",
"(",
"self",
".",
"_write_bu... | Flushes the current output buffer to the network.
The ``callback`` argument, if given, can be used for flow control:
it will be run when all flushed data has been written to the socket.
Note that only one flush callback can be outstanding at a time;
if another flush occurs before the pr... | [
"Flushes",
"the",
"current",
"output",
"buffer",
"to",
"the",
"network",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1051-L1101 |
26,732 | tornadoweb/tornado | tornado/web.py | RequestHandler.send_error | def send_error(self, status_code: int = 500, **kwargs: Any) -> None:
"""Sends the given HTTP error code to the browser.
If `flush()` has already been called, it is not possible to send
an error, so this method will simply terminate the response.
If output has been written but not yet fl... | python | def send_error(self, status_code: int = 500, **kwargs: Any) -> None:
"""Sends the given HTTP error code to the browser.
If `flush()` has already been called, it is not possible to send
an error, so this method will simply terminate the response.
If output has been written but not yet fl... | [
"def",
"send_error",
"(",
"self",
",",
"status_code",
":",
"int",
"=",
"500",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"if",
"self",
".",
"_headers_written",
":",
"gen_log",
".",
"error",
"(",
"\"Cannot send error response after headers w... | Sends the given HTTP error code to the browser.
If `flush()` has already been called, it is not possible to send
an error, so this method will simply terminate the response.
If output has been written but not yet flushed, it will be discarded
and replaced with the error page.
O... | [
"Sends",
"the",
"given",
"HTTP",
"error",
"code",
"to",
"the",
"browser",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1182-L1218 |
26,733 | tornadoweb/tornado | tornado/web.py | RequestHandler.write_error | def write_error(self, status_code: int, **kwargs: Any) -> None:
"""Override to implement custom error pages.
``write_error`` may call `write`, `render`, `set_header`, etc
to produce output as usual.
If this error was caused by an uncaught exception (including
HTTPError), an ``e... | python | def write_error(self, status_code: int, **kwargs: Any) -> None:
"""Override to implement custom error pages.
``write_error`` may call `write`, `render`, `set_header`, etc
to produce output as usual.
If this error was caused by an uncaught exception (including
HTTPError), an ``e... | [
"def",
"write_error",
"(",
"self",
",",
"status_code",
":",
"int",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"if",
"self",
".",
"settings",
".",
"get",
"(",
"\"serve_traceback\"",
")",
"and",
"\"exc_info\"",
"in",
"kwargs",
":",
"# i... | Override to implement custom error pages.
``write_error`` may call `write`, `render`, `set_header`, etc
to produce output as usual.
If this error was caused by an uncaught exception (including
HTTPError), an ``exc_info`` triple will be available as
``kwargs["exc_info"]``. Note... | [
"Override",
"to",
"implement",
"custom",
"error",
"pages",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1220-L1243 |
26,734 | tornadoweb/tornado | tornado/web.py | RequestHandler.locale | def locale(self) -> tornado.locale.Locale:
"""The locale for the current session.
Determined by either `get_user_locale`, which you can override to
set the locale based on, e.g., a user preference stored in a
database, or `get_browser_locale`, which uses the ``Accept-Language``
... | python | def locale(self) -> tornado.locale.Locale:
"""The locale for the current session.
Determined by either `get_user_locale`, which you can override to
set the locale based on, e.g., a user preference stored in a
database, or `get_browser_locale`, which uses the ``Accept-Language``
... | [
"def",
"locale",
"(",
"self",
")",
"->",
"tornado",
".",
"locale",
".",
"Locale",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_locale\"",
")",
":",
"loc",
"=",
"self",
".",
"get_user_locale",
"(",
")",
"if",
"loc",
"is",
"not",
"None",
":",
"... | The locale for the current session.
Determined by either `get_user_locale`, which you can override to
set the locale based on, e.g., a user preference stored in a
database, or `get_browser_locale`, which uses the ``Accept-Language``
header.
.. versionchanged: 4.1
Add... | [
"The",
"locale",
"for",
"the",
"current",
"session",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1246-L1264 |
26,735 | tornadoweb/tornado | tornado/web.py | RequestHandler.get_browser_locale | def get_browser_locale(self, default: str = "en_US") -> tornado.locale.Locale:
"""Determines the user's locale from ``Accept-Language`` header.
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
"""
if "Accept-Language" in self.request.headers:
languages = se... | python | def get_browser_locale(self, default: str = "en_US") -> tornado.locale.Locale:
"""Determines the user's locale from ``Accept-Language`` header.
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
"""
if "Accept-Language" in self.request.headers:
languages = se... | [
"def",
"get_browser_locale",
"(",
"self",
",",
"default",
":",
"str",
"=",
"\"en_US\"",
")",
"->",
"tornado",
".",
"locale",
".",
"Locale",
":",
"if",
"\"Accept-Language\"",
"in",
"self",
".",
"request",
".",
"headers",
":",
"languages",
"=",
"self",
".",
... | Determines the user's locale from ``Accept-Language`` header.
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 | [
"Determines",
"the",
"user",
"s",
"locale",
"from",
"Accept",
"-",
"Language",
"header",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1280-L1302 |
26,736 | tornadoweb/tornado | tornado/web.py | RequestHandler.current_user | def current_user(self) -> Any:
"""The authenticated user for this request.
This is set in one of two ways:
* A subclass may override `get_current_user()`, which will be called
automatically the first time ``self.current_user`` is accessed.
`get_current_user()` will only be ... | python | def current_user(self) -> Any:
"""The authenticated user for this request.
This is set in one of two ways:
* A subclass may override `get_current_user()`, which will be called
automatically the first time ``self.current_user`` is accessed.
`get_current_user()` will only be ... | [
"def",
"current_user",
"(",
"self",
")",
"->",
"Any",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_current_user\"",
")",
":",
"self",
".",
"_current_user",
"=",
"self",
".",
"get_current_user",
"(",
")",
"return",
"self",
".",
"_current_user"
] | The authenticated user for this request.
This is set in one of two ways:
* A subclass may override `get_current_user()`, which will be called
automatically the first time ``self.current_user`` is accessed.
`get_current_user()` will only be called once per request,
and is ... | [
"The",
"authenticated",
"user",
"for",
"this",
"request",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1305-L1338 |
26,737 | tornadoweb/tornado | tornado/web.py | RequestHandler._get_raw_xsrf_token | def _get_raw_xsrf_token(self) -> Tuple[Optional[int], bytes, float]:
"""Read or generate the xsrf token in its raw form.
The raw_xsrf_token is a tuple containing:
* version: the version of the cookie from which this token was read,
or None if we generated a new token in this request.... | python | def _get_raw_xsrf_token(self) -> Tuple[Optional[int], bytes, float]:
"""Read or generate the xsrf token in its raw form.
The raw_xsrf_token is a tuple containing:
* version: the version of the cookie from which this token was read,
or None if we generated a new token in this request.... | [
"def",
"_get_raw_xsrf_token",
"(",
"self",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"int",
"]",
",",
"bytes",
",",
"float",
"]",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_raw_xsrf_token\"",
")",
":",
"cookie",
"=",
"self",
".",
"get_cookie",
... | Read or generate the xsrf token in its raw form.
The raw_xsrf_token is a tuple containing:
* version: the version of the cookie from which this token was read,
or None if we generated a new token in this request.
* token: the raw token data; random (non-ascii) bytes.
* timest... | [
"Read",
"or",
"generate",
"the",
"xsrf",
"token",
"in",
"its",
"raw",
"form",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1424-L1448 |
26,738 | tornadoweb/tornado | tornado/web.py | RequestHandler._decode_xsrf_token | def _decode_xsrf_token(
self, cookie: str
) -> Tuple[Optional[int], Optional[bytes], Optional[float]]:
"""Convert a cookie string into a the tuple form returned by
_get_raw_xsrf_token.
"""
try:
m = _signed_value_version_re.match(utf8(cookie))
if m:
... | python | def _decode_xsrf_token(
self, cookie: str
) -> Tuple[Optional[int], Optional[bytes], Optional[float]]:
"""Convert a cookie string into a the tuple form returned by
_get_raw_xsrf_token.
"""
try:
m = _signed_value_version_re.match(utf8(cookie))
if m:
... | [
"def",
"_decode_xsrf_token",
"(",
"self",
",",
"cookie",
":",
"str",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"int",
"]",
",",
"Optional",
"[",
"bytes",
"]",
",",
"Optional",
"[",
"float",
"]",
"]",
":",
"try",
":",
"m",
"=",
"_signed_value_version_re... | Convert a cookie string into a the tuple form returned by
_get_raw_xsrf_token. | [
"Convert",
"a",
"cookie",
"string",
"into",
"a",
"the",
"tuple",
"form",
"returned",
"by",
"_get_raw_xsrf_token",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1450-L1484 |
26,739 | tornadoweb/tornado | tornado/web.py | RequestHandler.check_xsrf_cookie | def check_xsrf_cookie(self) -> None:
"""Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument.
To prevent cross-site request forgery, we set an ``_xsrf``
cookie and include the same value as a non-cookie
field with all ``POST`` requests. If the two do not match, we
r... | python | def check_xsrf_cookie(self) -> None:
"""Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument.
To prevent cross-site request forgery, we set an ``_xsrf``
cookie and include the same value as a non-cookie
field with all ``POST`` requests. If the two do not match, we
r... | [
"def",
"check_xsrf_cookie",
"(",
"self",
")",
"->",
"None",
":",
"# Prior to release 1.1.1, this check was ignored if the HTTP header",
"# ``X-Requested-With: XMLHTTPRequest`` was present. This exception",
"# has been shown to be insecure and has been removed. For more",
"# information pleas... | Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument.
To prevent cross-site request forgery, we set an ``_xsrf``
cookie and include the same value as a non-cookie
field with all ``POST`` requests. If the two do not match, we
reject the form submission as a potential forgery... | [
"Verifies",
"that",
"the",
"_xsrf",
"cookie",
"matches",
"the",
"_xsrf",
"argument",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1486-L1522 |
26,740 | tornadoweb/tornado | tornado/web.py | RequestHandler.static_url | def static_url(self, path: str, include_host: bool = None, **kwargs: Any) -> str:
"""Returns a static URL for the given relative static file path.
This method requires you set the ``static_path`` setting in your
application (which specifies the root directory of your static
files).
... | python | def static_url(self, path: str, include_host: bool = None, **kwargs: Any) -> str:
"""Returns a static URL for the given relative static file path.
This method requires you set the ``static_path`` setting in your
application (which specifies the root directory of your static
files).
... | [
"def",
"static_url",
"(",
"self",
",",
"path",
":",
"str",
",",
"include_host",
":",
"bool",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"str",
":",
"self",
".",
"require_setting",
"(",
"\"static_path\"",
",",
"\"static_url\"",
")",
"g... | Returns a static URL for the given relative static file path.
This method requires you set the ``static_path`` setting in your
application (which specifies the root directory of your static
files).
This method returns a versioned url (by default appending
``?v=<signature>``), w... | [
"Returns",
"a",
"static",
"URL",
"for",
"the",
"given",
"relative",
"static",
"file",
"path",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1543-L1577 |
26,741 | tornadoweb/tornado | tornado/web.py | RequestHandler.reverse_url | def reverse_url(self, name: str, *args: Any) -> str:
"""Alias for `Application.reverse_url`."""
return self.application.reverse_url(name, *args) | python | def reverse_url(self, name: str, *args: Any) -> str:
"""Alias for `Application.reverse_url`."""
return self.application.reverse_url(name, *args) | [
"def",
"reverse_url",
"(",
"self",
",",
"name",
":",
"str",
",",
"*",
"args",
":",
"Any",
")",
"->",
"str",
":",
"return",
"self",
".",
"application",
".",
"reverse_url",
"(",
"name",
",",
"*",
"args",
")"
] | Alias for `Application.reverse_url`. | [
"Alias",
"for",
"Application",
".",
"reverse_url",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1587-L1589 |
26,742 | tornadoweb/tornado | tornado/web.py | RequestHandler.compute_etag | def compute_etag(self) -> Optional[str]:
"""Computes the etag header to be used for this request.
By default uses a hash of the content written so far.
May be overridden to provide custom etag implementations,
or may return None to disable tornado's default etag support.
"""
... | python | def compute_etag(self) -> Optional[str]:
"""Computes the etag header to be used for this request.
By default uses a hash of the content written so far.
May be overridden to provide custom etag implementations,
or may return None to disable tornado's default etag support.
"""
... | [
"def",
"compute_etag",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"hasher",
"=",
"hashlib",
".",
"sha1",
"(",
")",
"for",
"part",
"in",
"self",
".",
"_write_buffer",
":",
"hasher",
".",
"update",
"(",
"part",
")",
"return",
"'\"%s\"'",
... | Computes the etag header to be used for this request.
By default uses a hash of the content written so far.
May be overridden to provide custom etag implementations,
or may return None to disable tornado's default etag support. | [
"Computes",
"the",
"etag",
"header",
"to",
"be",
"used",
"for",
"this",
"request",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1591-L1602 |
26,743 | tornadoweb/tornado | tornado/web.py | RequestHandler.check_etag_header | def check_etag_header(self) -> bool:
"""Checks the ``Etag`` header against requests's ``If-None-Match``.
Returns ``True`` if the request's Etag matches and a 304 should be
returned. For example::
self.set_etag_header()
if self.check_etag_header():
self.s... | python | def check_etag_header(self) -> bool:
"""Checks the ``Etag`` header against requests's ``If-None-Match``.
Returns ``True`` if the request's Etag matches and a 304 should be
returned. For example::
self.set_etag_header()
if self.check_etag_header():
self.s... | [
"def",
"check_etag_header",
"(",
"self",
")",
"->",
"bool",
":",
"computed_etag",
"=",
"utf8",
"(",
"self",
".",
"_headers",
".",
"get",
"(",
"\"Etag\"",
",",
"\"\"",
")",
")",
"# Find all weak and strong etag values from If-None-Match header",
"# because RFC 7232 all... | Checks the ``Etag`` header against requests's ``If-None-Match``.
Returns ``True`` if the request's Etag matches and a 304 should be
returned. For example::
self.set_etag_header()
if self.check_etag_header():
self.set_status(304)
return
T... | [
"Checks",
"the",
"Etag",
"header",
"against",
"requests",
"s",
"If",
"-",
"None",
"-",
"Match",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1615-L1653 |
26,744 | tornadoweb/tornado | tornado/web.py | RequestHandler._execute | async def _execute(
self, transforms: List["OutputTransform"], *args: bytes, **kwargs: bytes
) -> None:
"""Executes this request with the given output transforms."""
self._transforms = transforms
try:
if self.request.method not in self.SUPPORTED_METHODS:
r... | python | async def _execute(
self, transforms: List["OutputTransform"], *args: bytes, **kwargs: bytes
) -> None:
"""Executes this request with the given output transforms."""
self._transforms = transforms
try:
if self.request.method not in self.SUPPORTED_METHODS:
r... | [
"async",
"def",
"_execute",
"(",
"self",
",",
"transforms",
":",
"List",
"[",
"\"OutputTransform\"",
"]",
",",
"*",
"args",
":",
"bytes",
",",
"*",
"*",
"kwargs",
":",
"bytes",
")",
"->",
"None",
":",
"self",
".",
"_transforms",
"=",
"transforms",
"try... | Executes this request with the given output transforms. | [
"Executes",
"this",
"request",
"with",
"the",
"given",
"output",
"transforms",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1655-L1714 |
26,745 | tornadoweb/tornado | tornado/web.py | RequestHandler.log_exception | def log_exception(
self,
typ: "Optional[Type[BaseException]]",
value: Optional[BaseException],
tb: Optional[TracebackType],
) -> None:
"""Override to customize logging of uncaught exceptions.
By default logs instances of `HTTPError` as warnings without
stack ... | python | def log_exception(
self,
typ: "Optional[Type[BaseException]]",
value: Optional[BaseException],
tb: Optional[TracebackType],
) -> None:
"""Override to customize logging of uncaught exceptions.
By default logs instances of `HTTPError` as warnings without
stack ... | [
"def",
"log_exception",
"(",
"self",
",",
"typ",
":",
"\"Optional[Type[BaseException]]\"",
",",
"value",
":",
"Optional",
"[",
"BaseException",
"]",
",",
"tb",
":",
"Optional",
"[",
"TracebackType",
"]",
",",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
... | Override to customize logging of uncaught exceptions.
By default logs instances of `HTTPError` as warnings without
stack traces (on the ``tornado.general`` logger), and all
other exceptions as errors with stack traces (on the
``tornado.application`` logger).
.. versionadded:: 3... | [
"Override",
"to",
"customize",
"logging",
"of",
"uncaught",
"exceptions",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1763-L1789 |
26,746 | tornadoweb/tornado | tornado/web.py | Application.listen | def listen(self, port: int, address: str = "", **kwargs: Any) -> HTTPServer:
"""Starts an HTTP server for this application on the given port.
This is a convenience alias for creating an `.HTTPServer`
object and calling its listen method. Keyword arguments not
supported by `HTTPServer.l... | python | def listen(self, port: int, address: str = "", **kwargs: Any) -> HTTPServer:
"""Starts an HTTP server for this application on the given port.
This is a convenience alias for creating an `.HTTPServer`
object and calling its listen method. Keyword arguments not
supported by `HTTPServer.l... | [
"def",
"listen",
"(",
"self",
",",
"port",
":",
"int",
",",
"address",
":",
"str",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"HTTPServer",
":",
"server",
"=",
"HTTPServer",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"server",
"... | Starts an HTTP server for this application on the given port.
This is a convenience alias for creating an `.HTTPServer`
object and calling its listen method. Keyword arguments not
supported by `HTTPServer.listen <.TCPServer.listen>` are passed to the
`.HTTPServer` constructor. For adv... | [
"Starts",
"an",
"HTTP",
"server",
"for",
"this",
"application",
"on",
"the",
"given",
"port",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2092-L2113 |
26,747 | tornadoweb/tornado | tornado/web.py | Application.add_handlers | def add_handlers(self, host_pattern: str, host_handlers: _RuleList) -> None:
"""Appends the given handlers to our handler list.
Host patterns are processed sequentially in the order they were
added. All matching patterns will be considered.
"""
host_matcher = HostMatches(host_pa... | python | def add_handlers(self, host_pattern: str, host_handlers: _RuleList) -> None:
"""Appends the given handlers to our handler list.
Host patterns are processed sequentially in the order they were
added. All matching patterns will be considered.
"""
host_matcher = HostMatches(host_pa... | [
"def",
"add_handlers",
"(",
"self",
",",
"host_pattern",
":",
"str",
",",
"host_handlers",
":",
"_RuleList",
")",
"->",
"None",
":",
"host_matcher",
"=",
"HostMatches",
"(",
"host_pattern",
")",
"rule",
"=",
"Rule",
"(",
"host_matcher",
",",
"_ApplicationRoute... | Appends the given handlers to our handler list.
Host patterns are processed sequentially in the order they were
added. All matching patterns will be considered. | [
"Appends",
"the",
"given",
"handlers",
"to",
"our",
"handler",
"list",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2115-L2129 |
26,748 | tornadoweb/tornado | tornado/web.py | Application.get_handler_delegate | def get_handler_delegate(
self,
request: httputil.HTTPServerRequest,
target_class: Type[RequestHandler],
target_kwargs: Dict[str, Any] = None,
path_args: List[bytes] = None,
path_kwargs: Dict[str, bytes] = None,
) -> "_HandlerDelegate":
"""Returns `~.httputil.... | python | def get_handler_delegate(
self,
request: httputil.HTTPServerRequest,
target_class: Type[RequestHandler],
target_kwargs: Dict[str, Any] = None,
path_args: List[bytes] = None,
path_kwargs: Dict[str, bytes] = None,
) -> "_HandlerDelegate":
"""Returns `~.httputil.... | [
"def",
"get_handler_delegate",
"(",
"self",
",",
"request",
":",
"httputil",
".",
"HTTPServerRequest",
",",
"target_class",
":",
"Type",
"[",
"RequestHandler",
"]",
",",
"target_kwargs",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
",",
"path_args"... | Returns `~.httputil.HTTPMessageDelegate` that can serve a request
for application and `RequestHandler` subclass.
:arg httputil.HTTPServerRequest request: current HTTP request.
:arg RequestHandler target_class: a `RequestHandler` class.
:arg dict target_kwargs: keyword arguments for ``ta... | [
"Returns",
"~",
".",
"httputil",
".",
"HTTPMessageDelegate",
"that",
"can",
"serve",
"a",
"request",
"for",
"application",
"and",
"RequestHandler",
"subclass",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2187-L2207 |
26,749 | tornadoweb/tornado | tornado/web.py | Application.reverse_url | def reverse_url(self, name: str, *args: Any) -> str:
"""Returns a URL path for handler named ``name``
The handler must be added to the application as a named `URLSpec`.
Args will be substituted for capturing groups in the `URLSpec` regex.
They will be converted to strings if necessary,... | python | def reverse_url(self, name: str, *args: Any) -> str:
"""Returns a URL path for handler named ``name``
The handler must be added to the application as a named `URLSpec`.
Args will be substituted for capturing groups in the `URLSpec` regex.
They will be converted to strings if necessary,... | [
"def",
"reverse_url",
"(",
"self",
",",
"name",
":",
"str",
",",
"*",
"args",
":",
"Any",
")",
"->",
"str",
":",
"reversed_url",
"=",
"self",
".",
"default_router",
".",
"reverse_url",
"(",
"name",
",",
"*",
"args",
")",
"if",
"reversed_url",
"is",
"... | Returns a URL path for handler named ``name``
The handler must be added to the application as a named `URLSpec`.
Args will be substituted for capturing groups in the `URLSpec` regex.
They will be converted to strings if necessary, encoded as utf8,
and url-escaped. | [
"Returns",
"a",
"URL",
"path",
"for",
"handler",
"named",
"name"
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2209-L2222 |
26,750 | tornadoweb/tornado | tornado/web.py | StaticFileHandler.compute_etag | def compute_etag(self) -> Optional[str]:
"""Sets the ``Etag`` header based on static url version.
This allows efficient ``If-None-Match`` checks against cached
versions, and sends the correct ``Etag`` for a partial response
(i.e. the same ``Etag`` as the full file).
.. versiona... | python | def compute_etag(self) -> Optional[str]:
"""Sets the ``Etag`` header based on static url version.
This allows efficient ``If-None-Match`` checks against cached
versions, and sends the correct ``Etag`` for a partial response
(i.e. the same ``Etag`` as the full file).
.. versiona... | [
"def",
"compute_etag",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"assert",
"self",
".",
"absolute_path",
"is",
"not",
"None",
"version_hash",
"=",
"self",
".",
"_get_cached_version",
"(",
"self",
".",
"absolute_path",
")",
"if",
"not",
"ver... | Sets the ``Etag`` header based on static url version.
This allows efficient ``If-None-Match`` checks against cached
versions, and sends the correct ``Etag`` for a partial response
(i.e. the same ``Etag`` as the full file).
.. versionadded:: 3.1 | [
"Sets",
"the",
"Etag",
"header",
"based",
"on",
"static",
"url",
"version",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2655-L2668 |
26,751 | tornadoweb/tornado | tornado/web.py | StaticFileHandler.set_headers | def set_headers(self) -> None:
"""Sets the content and caching headers on the response.
.. versionadded:: 3.1
"""
self.set_header("Accept-Ranges", "bytes")
self.set_etag_header()
if self.modified is not None:
self.set_header("Last-Modified", self.modified)
... | python | def set_headers(self) -> None:
"""Sets the content and caching headers on the response.
.. versionadded:: 3.1
"""
self.set_header("Accept-Ranges", "bytes")
self.set_etag_header()
if self.modified is not None:
self.set_header("Last-Modified", self.modified)
... | [
"def",
"set_headers",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"set_header",
"(",
"\"Accept-Ranges\"",
",",
"\"bytes\"",
")",
"self",
".",
"set_etag_header",
"(",
")",
"if",
"self",
".",
"modified",
"is",
"not",
"None",
":",
"self",
".",
"set_he... | Sets the content and caching headers on the response.
.. versionadded:: 3.1 | [
"Sets",
"the",
"content",
"and",
"caching",
"headers",
"on",
"the",
"response",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2670-L2693 |
26,752 | tornadoweb/tornado | tornado/web.py | StaticFileHandler.should_return_304 | def should_return_304(self) -> bool:
"""Returns True if the headers indicate that we should return 304.
.. versionadded:: 3.1
"""
# If client sent If-None-Match, use it, ignore If-Modified-Since
if self.request.headers.get("If-None-Match"):
return self.check_etag_hea... | python | def should_return_304(self) -> bool:
"""Returns True if the headers indicate that we should return 304.
.. versionadded:: 3.1
"""
# If client sent If-None-Match, use it, ignore If-Modified-Since
if self.request.headers.get("If-None-Match"):
return self.check_etag_hea... | [
"def",
"should_return_304",
"(",
"self",
")",
"->",
"bool",
":",
"# If client sent If-None-Match, use it, ignore If-Modified-Since",
"if",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"\"If-None-Match\"",
")",
":",
"return",
"self",
".",
"check_etag_header... | Returns True if the headers indicate that we should return 304.
.. versionadded:: 3.1 | [
"Returns",
"True",
"if",
"the",
"headers",
"indicate",
"that",
"we",
"should",
"return",
"304",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2695-L2715 |
26,753 | tornadoweb/tornado | tornado/web.py | StaticFileHandler.get_absolute_path | def get_absolute_path(cls, root: str, path: str) -> str:
"""Returns the absolute location of ``path`` relative to ``root``.
``root`` is the path configured for this `StaticFileHandler`
(in most cases the ``static_path`` `Application` setting).
This class method may be overridden in sub... | python | def get_absolute_path(cls, root: str, path: str) -> str:
"""Returns the absolute location of ``path`` relative to ``root``.
``root`` is the path configured for this `StaticFileHandler`
(in most cases the ``static_path`` `Application` setting).
This class method may be overridden in sub... | [
"def",
"get_absolute_path",
"(",
"cls",
",",
"root",
":",
"str",
",",
"path",
":",
"str",
")",
"->",
"str",
":",
"abspath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"path",
")",
")",
"return",... | Returns the absolute location of ``path`` relative to ``root``.
``root`` is the path configured for this `StaticFileHandler`
(in most cases the ``static_path`` `Application` setting).
This class method may be overridden in subclasses. By default
it returns a filesystem path, but other... | [
"Returns",
"the",
"absolute",
"location",
"of",
"path",
"relative",
"to",
"root",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2718-L2732 |
26,754 | tornadoweb/tornado | tornado/web.py | StaticFileHandler.get_content | def get_content(
cls, abspath: str, start: int = None, end: int = None
) -> Generator[bytes, None, None]:
"""Retrieve the content of the requested resource which is located
at the given absolute path.
This class method may be overridden by subclasses. Note that its
signatur... | python | def get_content(
cls, abspath: str, start: int = None, end: int = None
) -> Generator[bytes, None, None]:
"""Retrieve the content of the requested resource which is located
at the given absolute path.
This class method may be overridden by subclasses. Note that its
signatur... | [
"def",
"get_content",
"(",
"cls",
",",
"abspath",
":",
"str",
",",
"start",
":",
"int",
"=",
"None",
",",
"end",
":",
"int",
"=",
"None",
")",
"->",
"Generator",
"[",
"bytes",
",",
"None",
",",
"None",
"]",
":",
"with",
"open",
"(",
"abspath",
",... | Retrieve the content of the requested resource which is located
at the given absolute path.
This class method may be overridden by subclasses. Note that its
signature is different from other overridable class methods
(no ``settings`` argument); this is deliberate to ensure that
... | [
"Retrieve",
"the",
"content",
"of",
"the",
"requested",
"resource",
"which",
"is",
"located",
"at",
"the",
"given",
"absolute",
"path",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2785-L2821 |
26,755 | tornadoweb/tornado | tornado/web.py | StaticFileHandler.get_modified_time | def get_modified_time(self) -> Optional[datetime.datetime]:
"""Returns the time that ``self.absolute_path`` was last modified.
May be overridden in subclasses. Should return a `~datetime.datetime`
object or None.
.. versionadded:: 3.1
"""
stat_result = self._stat()
... | python | def get_modified_time(self) -> Optional[datetime.datetime]:
"""Returns the time that ``self.absolute_path`` was last modified.
May be overridden in subclasses. Should return a `~datetime.datetime`
object or None.
.. versionadded:: 3.1
"""
stat_result = self._stat()
... | [
"def",
"get_modified_time",
"(",
"self",
")",
"->",
"Optional",
"[",
"datetime",
".",
"datetime",
"]",
":",
"stat_result",
"=",
"self",
".",
"_stat",
"(",
")",
"# NOTE: Historically, this used stat_result[stat.ST_MTIME],",
"# which truncates the fractional portion of the ti... | Returns the time that ``self.absolute_path`` was last modified.
May be overridden in subclasses. Should return a `~datetime.datetime`
object or None.
.. versionadded:: 3.1 | [
"Returns",
"the",
"time",
"that",
"self",
".",
"absolute_path",
"was",
"last",
"modified",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2861-L2879 |
26,756 | tornadoweb/tornado | tornado/web.py | StaticFileHandler.get_cache_time | def get_cache_time(
self, path: str, modified: Optional[datetime.datetime], mime_type: str
) -> int:
"""Override to customize cache control behavior.
Return a positive number of seconds to make the result
cacheable for that amount of time or 0 to mark resource as
cacheable f... | python | def get_cache_time(
self, path: str, modified: Optional[datetime.datetime], mime_type: str
) -> int:
"""Override to customize cache control behavior.
Return a positive number of seconds to make the result
cacheable for that amount of time or 0 to mark resource as
cacheable f... | [
"def",
"get_cache_time",
"(",
"self",
",",
"path",
":",
"str",
",",
"modified",
":",
"Optional",
"[",
"datetime",
".",
"datetime",
"]",
",",
"mime_type",
":",
"str",
")",
"->",
"int",
":",
"return",
"self",
".",
"CACHE_MAX_AGE",
"if",
"\"v\"",
"in",
"s... | Override to customize cache control behavior.
Return a positive number of seconds to make the result
cacheable for that amount of time or 0 to mark resource as
cacheable for an unspecified amount of time (subject to
browser heuristics).
By default returns cache expiry of 10 yea... | [
"Override",
"to",
"customize",
"cache",
"control",
"behavior",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2906-L2919 |
26,757 | tornadoweb/tornado | tornado/web.py | StaticFileHandler.make_static_url | def make_static_url(
cls, settings: Dict[str, Any], path: str, include_version: bool = True
) -> str:
"""Constructs a versioned url for the given path.
This method may be overridden in subclasses (but note that it
is a class method rather than an instance method). Subclasses
... | python | def make_static_url(
cls, settings: Dict[str, Any], path: str, include_version: bool = True
) -> str:
"""Constructs a versioned url for the given path.
This method may be overridden in subclasses (but note that it
is a class method rather than an instance method). Subclasses
... | [
"def",
"make_static_url",
"(",
"cls",
",",
"settings",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"path",
":",
"str",
",",
"include_version",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"url",
"=",
"settings",
".",
"get",
"(",
"\"static_url_... | Constructs a versioned url for the given path.
This method may be overridden in subclasses (but note that it
is a class method rather than an instance method). Subclasses
are only required to implement the signature
``make_static_url(cls, settings, path)``; other keyword
argume... | [
"Constructs",
"a",
"versioned",
"url",
"for",
"the",
"given",
"path",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2922-L2951 |
26,758 | tornadoweb/tornado | tornado/web.py | StaticFileHandler.parse_url_path | def parse_url_path(self, url_path: str) -> str:
"""Converts a static URL path into a filesystem path.
``url_path`` is the path component of the URL with
``static_url_prefix`` removed. The return value should be
filesystem path relative to ``static_path``.
This is the inverse o... | python | def parse_url_path(self, url_path: str) -> str:
"""Converts a static URL path into a filesystem path.
``url_path`` is the path component of the URL with
``static_url_prefix`` removed. The return value should be
filesystem path relative to ``static_path``.
This is the inverse o... | [
"def",
"parse_url_path",
"(",
"self",
",",
"url_path",
":",
"str",
")",
"->",
"str",
":",
"if",
"os",
".",
"path",
".",
"sep",
"!=",
"\"/\"",
":",
"url_path",
"=",
"url_path",
".",
"replace",
"(",
"\"/\"",
",",
"os",
".",
"path",
".",
"sep",
")",
... | Converts a static URL path into a filesystem path.
``url_path`` is the path component of the URL with
``static_url_prefix`` removed. The return value should be
filesystem path relative to ``static_path``.
This is the inverse of `make_static_url`. | [
"Converts",
"a",
"static",
"URL",
"path",
"into",
"a",
"filesystem",
"path",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2953-L2964 |
26,759 | tornadoweb/tornado | tornado/web.py | StaticFileHandler.get_version | def get_version(cls, settings: Dict[str, Any], path: str) -> Optional[str]:
"""Generate the version string to be used in static URLs.
``settings`` is the `Application.settings` dictionary and ``path``
is the relative location of the requested asset on the filesystem.
The returned value ... | python | def get_version(cls, settings: Dict[str, Any], path: str) -> Optional[str]:
"""Generate the version string to be used in static URLs.
``settings`` is the `Application.settings` dictionary and ``path``
is the relative location of the requested asset on the filesystem.
The returned value ... | [
"def",
"get_version",
"(",
"cls",
",",
"settings",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"path",
":",
"str",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"abs_path",
"=",
"cls",
".",
"get_absolute_path",
"(",
"settings",
"[",
"\"static_path\""... | Generate the version string to be used in static URLs.
``settings`` is the `Application.settings` dictionary and ``path``
is the relative location of the requested asset on the filesystem.
The returned value should be a string, or ``None`` if no version
could be determined.
.. ... | [
"Generate",
"the",
"version",
"string",
"to",
"be",
"used",
"in",
"static",
"URLs",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2967-L2981 |
26,760 | tornadoweb/tornado | tornado/web.py | UIModule.render_string | def render_string(self, path: str, **kwargs: Any) -> bytes:
"""Renders a template and returns it as a string."""
return self.handler.render_string(path, **kwargs) | python | def render_string(self, path: str, **kwargs: Any) -> bytes:
"""Renders a template and returns it as a string."""
return self.handler.render_string(path, **kwargs) | [
"def",
"render_string",
"(",
"self",
",",
"path",
":",
"str",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"bytes",
":",
"return",
"self",
".",
"handler",
".",
"render_string",
"(",
"path",
",",
"*",
"*",
"kwargs",
")"
] | Renders a template and returns it as a string. | [
"Renders",
"a",
"template",
"and",
"returns",
"it",
"as",
"a",
"string",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L3241-L3243 |
26,761 | tornadoweb/tornado | tornado/escape.py | xhtml_unescape | def xhtml_unescape(value: Union[str, bytes]) -> str:
"""Un-escapes an XML-escaped string."""
return re.sub(r"&(#?)(\w+?);", _convert_entity, _unicode(value)) | python | def xhtml_unescape(value: Union[str, bytes]) -> str:
"""Un-escapes an XML-escaped string."""
return re.sub(r"&(#?)(\w+?);", _convert_entity, _unicode(value)) | [
"def",
"xhtml_unescape",
"(",
"value",
":",
"Union",
"[",
"str",
",",
"bytes",
"]",
")",
"->",
"str",
":",
"return",
"re",
".",
"sub",
"(",
"r\"&(#?)(\\w+?);\"",
",",
"_convert_entity",
",",
"_unicode",
"(",
"value",
")",
")"
] | Un-escapes an XML-escaped string. | [
"Un",
"-",
"escapes",
"an",
"XML",
"-",
"escaped",
"string",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L59-L61 |
26,762 | tornadoweb/tornado | tornado/escape.py | json_decode | def json_decode(value: Union[str, bytes]) -> Any:
"""Returns Python objects for the given JSON string.
Supports both `str` and `bytes` inputs.
"""
return json.loads(to_basestring(value)) | python | def json_decode(value: Union[str, bytes]) -> Any:
"""Returns Python objects for the given JSON string.
Supports both `str` and `bytes` inputs.
"""
return json.loads(to_basestring(value)) | [
"def",
"json_decode",
"(",
"value",
":",
"Union",
"[",
"str",
",",
"bytes",
"]",
")",
"->",
"Any",
":",
"return",
"json",
".",
"loads",
"(",
"to_basestring",
"(",
"value",
")",
")"
] | Returns Python objects for the given JSON string.
Supports both `str` and `bytes` inputs. | [
"Returns",
"Python",
"objects",
"for",
"the",
"given",
"JSON",
"string",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L78-L83 |
26,763 | tornadoweb/tornado | tornado/escape.py | url_unescape | def url_unescape( # noqa: F811
value: Union[str, bytes], encoding: Optional[str] = "utf-8", plus: bool = True
) -> Union[str, bytes]:
"""Decodes the given value from a URL.
The argument may be either a byte or unicode string.
If encoding is None, the result will be a byte string. Otherwise,
the ... | python | def url_unescape( # noqa: F811
value: Union[str, bytes], encoding: Optional[str] = "utf-8", plus: bool = True
) -> Union[str, bytes]:
"""Decodes the given value from a URL.
The argument may be either a byte or unicode string.
If encoding is None, the result will be a byte string. Otherwise,
the ... | [
"def",
"url_unescape",
"(",
"# noqa: F811",
"value",
":",
"Union",
"[",
"str",
",",
"bytes",
"]",
",",
"encoding",
":",
"Optional",
"[",
"str",
"]",
"=",
"\"utf-8\"",
",",
"plus",
":",
"bool",
"=",
"True",
")",
"->",
"Union",
"[",
"str",
",",
"bytes"... | Decodes the given value from a URL.
The argument may be either a byte or unicode string.
If encoding is None, the result will be a byte string. Otherwise,
the result is a unicode string in the specified encoding.
If ``plus`` is true (the default), plus signs will be interpreted
as spaces (litera... | [
"Decodes",
"the",
"given",
"value",
"from",
"a",
"URL",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L118-L144 |
26,764 | tornadoweb/tornado | tornado/escape.py | parse_qs_bytes | def parse_qs_bytes(
qs: str, keep_blank_values: bool = False, strict_parsing: bool = False
) -> Dict[str, List[bytes]]:
"""Parses a query string like urlparse.parse_qs, but returns the
values as byte strings.
Keys still become type str (interpreted as latin1 in python3!)
because it's too painful to... | python | def parse_qs_bytes(
qs: str, keep_blank_values: bool = False, strict_parsing: bool = False
) -> Dict[str, List[bytes]]:
"""Parses a query string like urlparse.parse_qs, but returns the
values as byte strings.
Keys still become type str (interpreted as latin1 in python3!)
because it's too painful to... | [
"def",
"parse_qs_bytes",
"(",
"qs",
":",
"str",
",",
"keep_blank_values",
":",
"bool",
"=",
"False",
",",
"strict_parsing",
":",
"bool",
"=",
"False",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"bytes",
"]",
"]",
":",
"# This is gross, but python3 do... | Parses a query string like urlparse.parse_qs, but returns the
values as byte strings.
Keys still become type str (interpreted as latin1 in python3!)
because it's too painful to keep them as byte strings in
python3 and in practice they're nearly always ascii anyway. | [
"Parses",
"a",
"query",
"string",
"like",
"urlparse",
".",
"parse_qs",
"but",
"returns",
"the",
"values",
"as",
"byte",
"strings",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L147-L165 |
26,765 | tornadoweb/tornado | tornado/escape.py | linkify | def linkify(
text: Union[str, bytes],
shorten: bool = False,
extra_params: Union[str, Callable[[str], str]] = "",
require_protocol: bool = False,
permitted_protocols: List[str] = ["http", "https"],
) -> str:
"""Converts plain text into HTML with links.
For example: ``linkify("Hello http://t... | python | def linkify(
text: Union[str, bytes],
shorten: bool = False,
extra_params: Union[str, Callable[[str], str]] = "",
require_protocol: bool = False,
permitted_protocols: List[str] = ["http", "https"],
) -> str:
"""Converts plain text into HTML with links.
For example: ``linkify("Hello http://t... | [
"def",
"linkify",
"(",
"text",
":",
"Union",
"[",
"str",
",",
"bytes",
"]",
",",
"shorten",
":",
"bool",
"=",
"False",
",",
"extra_params",
":",
"Union",
"[",
"str",
",",
"Callable",
"[",
"[",
"str",
"]",
",",
"str",
"]",
"]",
"=",
"\"\"",
",",
... | Converts plain text into HTML with links.
For example: ``linkify("Hello http://tornadoweb.org!")`` would return
``Hello <a href="http://tornadoweb.org">http://tornadoweb.org</a>!``
Parameters:
* ``shorten``: Long urls will be shortened for display.
* ``extra_params``: Extra text to include in th... | [
"Converts",
"plain",
"text",
"into",
"HTML",
"with",
"links",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L273-L375 |
26,766 | tornadoweb/tornado | tornado/ioloop.py | IOLoop.clear_current | def clear_current() -> None:
"""Clears the `IOLoop` for the current thread.
Intended primarily for use by test frameworks in between tests.
.. versionchanged:: 5.0
This method also clears the current `asyncio` event loop.
"""
old = IOLoop.current(instance=False)
... | python | def clear_current() -> None:
"""Clears the `IOLoop` for the current thread.
Intended primarily for use by test frameworks in between tests.
.. versionchanged:: 5.0
This method also clears the current `asyncio` event loop.
"""
old = IOLoop.current(instance=False)
... | [
"def",
"clear_current",
"(",
")",
"->",
"None",
":",
"old",
"=",
"IOLoop",
".",
"current",
"(",
"instance",
"=",
"False",
")",
"if",
"old",
"is",
"not",
"None",
":",
"old",
".",
"_clear_current_hook",
"(",
")",
"if",
"asyncio",
"is",
"None",
":",
"IO... | Clears the `IOLoop` for the current thread.
Intended primarily for use by test frameworks in between tests.
.. versionchanged:: 5.0
This method also clears the current `asyncio` event loop. | [
"Clears",
"the",
"IOLoop",
"for",
"the",
"current",
"thread",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L301-L313 |
26,767 | tornadoweb/tornado | tornado/ioloop.py | IOLoop.add_handler | def add_handler( # noqa: F811
self, fd: Union[int, _Selectable], handler: Callable[..., None], events: int
) -> None:
"""Registers the given handler to receive the given events for ``fd``.
The ``fd`` argument may either be an integer file descriptor or
a file-like object with a ``f... | python | def add_handler( # noqa: F811
self, fd: Union[int, _Selectable], handler: Callable[..., None], events: int
) -> None:
"""Registers the given handler to receive the given events for ``fd``.
The ``fd`` argument may either be an integer file descriptor or
a file-like object with a ``f... | [
"def",
"add_handler",
"(",
"# noqa: F811",
"self",
",",
"fd",
":",
"Union",
"[",
"int",
",",
"_Selectable",
"]",
",",
"handler",
":",
"Callable",
"[",
"...",
",",
"None",
"]",
",",
"events",
":",
"int",
")",
"->",
"None",
":",
"raise",
"NotImplementedE... | Registers the given handler to receive the given events for ``fd``.
The ``fd`` argument may either be an integer file descriptor or
a file-like object with a ``fileno()`` and ``close()`` method.
The ``events`` argument is a bitwise or of the constants
``IOLoop.READ``, ``IOLoop.WRITE``,... | [
"Registers",
"the",
"given",
"handler",
"to",
"receive",
"the",
"given",
"events",
"for",
"fd",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L382-L399 |
26,768 | tornadoweb/tornado | tornado/ioloop.py | IOLoop.run_in_executor | def run_in_executor(
self,
executor: Optional[concurrent.futures.Executor],
func: Callable[..., _T],
*args: Any
) -> Awaitable[_T]:
"""Runs a function in a ``concurrent.futures.Executor``. If
``executor`` is ``None``, the IO loop's default executor will be used.
... | python | def run_in_executor(
self,
executor: Optional[concurrent.futures.Executor],
func: Callable[..., _T],
*args: Any
) -> Awaitable[_T]:
"""Runs a function in a ``concurrent.futures.Executor``. If
``executor`` is ``None``, the IO loop's default executor will be used.
... | [
"def",
"run_in_executor",
"(",
"self",
",",
"executor",
":",
"Optional",
"[",
"concurrent",
".",
"futures",
".",
"Executor",
"]",
",",
"func",
":",
"Callable",
"[",
"...",
",",
"_T",
"]",
",",
"*",
"args",
":",
"Any",
")",
"->",
"Awaitable",
"[",
"_T... | Runs a function in a ``concurrent.futures.Executor``. If
``executor`` is ``None``, the IO loop's default executor will be used.
Use `functools.partial` to pass keyword arguments to ``func``.
.. versionadded:: 5.0 | [
"Runs",
"a",
"function",
"in",
"a",
"concurrent",
".",
"futures",
".",
"Executor",
".",
"If",
"executor",
"is",
"None",
"the",
"IO",
"loop",
"s",
"default",
"executor",
"will",
"be",
"used",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L700-L726 |
26,769 | tornadoweb/tornado | tornado/httputil.py | url_concat | def url_concat(
url: str,
args: Union[
None, Dict[str, str], List[Tuple[str, str]], Tuple[Tuple[str, str], ...]
],
) -> str:
"""Concatenate url and arguments regardless of whether
url has existing query parameters.
``args`` may be either a dictionary or a list of key-value pairs
(th... | python | def url_concat(
url: str,
args: Union[
None, Dict[str, str], List[Tuple[str, str]], Tuple[Tuple[str, str], ...]
],
) -> str:
"""Concatenate url and arguments regardless of whether
url has existing query parameters.
``args`` may be either a dictionary or a list of key-value pairs
(th... | [
"def",
"url_concat",
"(",
"url",
":",
"str",
",",
"args",
":",
"Union",
"[",
"None",
",",
"Dict",
"[",
"str",
",",
"str",
"]",
",",
"List",
"[",
"Tuple",
"[",
"str",
",",
"str",
"]",
"]",
",",
"Tuple",
"[",
"Tuple",
"[",
"str",
",",
"str",
"]... | Concatenate url and arguments regardless of whether
url has existing query parameters.
``args`` may be either a dictionary or a list of key-value pairs
(the latter allows for multiple values with the same key.
>>> url_concat("http://example.com/foo", dict(c="d"))
'http://example.com/foo?c=d'
>... | [
"Concatenate",
"url",
"and",
"arguments",
"regardless",
"of",
"whether",
"url",
"has",
"existing",
"query",
"parameters",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L631-L675 |
26,770 | tornadoweb/tornado | tornado/httputil.py | _parse_request_range | def _parse_request_range(
range_header: str
) -> Optional[Tuple[Optional[int], Optional[int]]]:
"""Parses a Range header.
Returns either ``None`` or tuple ``(start, end)``.
Note that while the HTTP headers use inclusive byte positions,
this method returns indexes suitable for use in slices.
>>... | python | def _parse_request_range(
range_header: str
) -> Optional[Tuple[Optional[int], Optional[int]]]:
"""Parses a Range header.
Returns either ``None`` or tuple ``(start, end)``.
Note that while the HTTP headers use inclusive byte positions,
this method returns indexes suitable for use in slices.
>>... | [
"def",
"_parse_request_range",
"(",
"range_header",
":",
"str",
")",
"->",
"Optional",
"[",
"Tuple",
"[",
"Optional",
"[",
"int",
"]",
",",
"Optional",
"[",
"int",
"]",
"]",
"]",
":",
"unit",
",",
"_",
",",
"value",
"=",
"range_header",
".",
"partition... | Parses a Range header.
Returns either ``None`` or tuple ``(start, end)``.
Note that while the HTTP headers use inclusive byte positions,
this method returns indexes suitable for use in slices.
>>> start, end = _parse_request_range("bytes=1-2")
>>> start, end
(1, 3)
>>> [0, 1, 2, 3, 4][star... | [
"Parses",
"a",
"Range",
"header",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L692-L740 |
26,771 | tornadoweb/tornado | tornado/httputil.py | parse_body_arguments | def parse_body_arguments(
content_type: str,
body: bytes,
arguments: Dict[str, List[bytes]],
files: Dict[str, List[HTTPFile]],
headers: HTTPHeaders = None,
) -> None:
"""Parses a form request body.
Supports ``application/x-www-form-urlencoded`` and
``multipart/form-data``. The ``conten... | python | def parse_body_arguments(
content_type: str,
body: bytes,
arguments: Dict[str, List[bytes]],
files: Dict[str, List[HTTPFile]],
headers: HTTPHeaders = None,
) -> None:
"""Parses a form request body.
Supports ``application/x-www-form-urlencoded`` and
``multipart/form-data``. The ``conten... | [
"def",
"parse_body_arguments",
"(",
"content_type",
":",
"str",
",",
"body",
":",
"bytes",
",",
"arguments",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"bytes",
"]",
"]",
",",
"files",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"HTTPFile",
"]",
"]",
... | Parses a form request body.
Supports ``application/x-www-form-urlencoded`` and
``multipart/form-data``. The ``content_type`` parameter should be
a string and ``body`` should be a byte string. The ``arguments``
and ``files`` parameters are dictionaries that will be updated
with the parsed contents... | [
"Parses",
"a",
"form",
"request",
"body",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L765-L810 |
26,772 | tornadoweb/tornado | tornado/httputil.py | format_timestamp | def format_timestamp(
ts: Union[int, float, tuple, time.struct_time, datetime.datetime]
) -> str:
"""Formats a timestamp in the format used by HTTP.
The argument may be a numeric timestamp as returned by `time.time`,
a time tuple as returned by `time.gmtime`, or a `datetime.datetime`
object.
>... | python | def format_timestamp(
ts: Union[int, float, tuple, time.struct_time, datetime.datetime]
) -> str:
"""Formats a timestamp in the format used by HTTP.
The argument may be a numeric timestamp as returned by `time.time`,
a time tuple as returned by `time.gmtime`, or a `datetime.datetime`
object.
>... | [
"def",
"format_timestamp",
"(",
"ts",
":",
"Union",
"[",
"int",
",",
"float",
",",
"tuple",
",",
"time",
".",
"struct_time",
",",
"datetime",
".",
"datetime",
"]",
")",
"->",
"str",
":",
"if",
"isinstance",
"(",
"ts",
",",
"(",
"int",
",",
"float",
... | Formats a timestamp in the format used by HTTP.
The argument may be a numeric timestamp as returned by `time.time`,
a time tuple as returned by `time.gmtime`, or a `datetime.datetime`
object.
>>> format_timestamp(1359312200)
'Sun, 27 Jan 2013 18:43:20 GMT' | [
"Formats",
"a",
"timestamp",
"in",
"the",
"format",
"used",
"by",
"HTTP",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L871-L891 |
26,773 | tornadoweb/tornado | tornado/httputil.py | _parse_header | def _parse_header(line: str) -> Tuple[str, Dict[str, str]]:
r"""Parse a Content-type like header.
Return the main content-type and a dictionary of options.
>>> d = "form-data; foo=\"b\\\\a\\\"r\"; file*=utf-8''T%C3%A4st"
>>> ct, d = _parse_header(d)
>>> ct
'form-data'
>>> d['file'] == r'T\... | python | def _parse_header(line: str) -> Tuple[str, Dict[str, str]]:
r"""Parse a Content-type like header.
Return the main content-type and a dictionary of options.
>>> d = "form-data; foo=\"b\\\\a\\\"r\"; file*=utf-8''T%C3%A4st"
>>> ct, d = _parse_header(d)
>>> ct
'form-data'
>>> d['file'] == r'T\... | [
"def",
"_parse_header",
"(",
"line",
":",
"str",
")",
"->",
"Tuple",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"parts",
"=",
"_parseparam",
"(",
"\";\"",
"+",
"line",
")",
"key",
"=",
"next",
"(",
"parts",
")",
"# decode_param... | r"""Parse a Content-type like header.
Return the main content-type and a dictionary of options.
>>> d = "form-data; foo=\"b\\\\a\\\"r\"; file*=utf-8''T%C3%A4st"
>>> ct, d = _parse_header(d)
>>> ct
'form-data'
>>> d['file'] == r'T\u00e4st'.encode('ascii').decode('unicode_escape')
True
>... | [
"r",
"Parse",
"a",
"Content",
"-",
"type",
"like",
"header",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L961-L993 |
26,774 | tornadoweb/tornado | tornado/httputil.py | _encode_header | def _encode_header(key: str, pdict: Dict[str, str]) -> str:
"""Inverse of _parse_header.
>>> _encode_header('permessage-deflate',
... {'client_max_window_bits': 15, 'client_no_context_takeover': None})
'permessage-deflate; client_max_window_bits=15; client_no_context_takeover'
"""
if not pd... | python | def _encode_header(key: str, pdict: Dict[str, str]) -> str:
"""Inverse of _parse_header.
>>> _encode_header('permessage-deflate',
... {'client_max_window_bits': 15, 'client_no_context_takeover': None})
'permessage-deflate; client_max_window_bits=15; client_no_context_takeover'
"""
if not pd... | [
"def",
"_encode_header",
"(",
"key",
":",
"str",
",",
"pdict",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"str",
":",
"if",
"not",
"pdict",
":",
"return",
"key",
"out",
"=",
"[",
"key",
"]",
"# Sort the parameters just to make it easy to test.",
... | Inverse of _parse_header.
>>> _encode_header('permessage-deflate',
... {'client_max_window_bits': 15, 'client_no_context_takeover': None})
'permessage-deflate; client_max_window_bits=15; client_no_context_takeover' | [
"Inverse",
"of",
"_parse_header",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L996-L1013 |
26,775 | tornadoweb/tornado | tornado/httputil.py | qs_to_qsl | def qs_to_qsl(qs: Dict[str, List[AnyStr]]) -> Iterable[Tuple[str, AnyStr]]:
"""Generator converting a result of ``parse_qs`` back to name-value pairs.
.. versionadded:: 5.0
"""
for k, vs in qs.items():
for v in vs:
yield (k, v) | python | def qs_to_qsl(qs: Dict[str, List[AnyStr]]) -> Iterable[Tuple[str, AnyStr]]:
"""Generator converting a result of ``parse_qs`` back to name-value pairs.
.. versionadded:: 5.0
"""
for k, vs in qs.items():
for v in vs:
yield (k, v) | [
"def",
"qs_to_qsl",
"(",
"qs",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"AnyStr",
"]",
"]",
")",
"->",
"Iterable",
"[",
"Tuple",
"[",
"str",
",",
"AnyStr",
"]",
"]",
":",
"for",
"k",
",",
"vs",
"in",
"qs",
".",
"items",
"(",
")",
":",
"for"... | Generator converting a result of ``parse_qs`` back to name-value pairs.
.. versionadded:: 5.0 | [
"Generator",
"converting",
"a",
"result",
"of",
"parse_qs",
"back",
"to",
"name",
"-",
"value",
"pairs",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L1056-L1063 |
26,776 | tornadoweb/tornado | tornado/httputil.py | _unquote_cookie | def _unquote_cookie(s: str) -> str:
"""Handle double quotes and escaping in cookie values.
This method is copied verbatim from the Python 3.5 standard
library (http.cookies._unquote) so we don't have to depend on
non-public interfaces.
"""
# If there aren't any doublequotes,
# then there ca... | python | def _unquote_cookie(s: str) -> str:
"""Handle double quotes and escaping in cookie values.
This method is copied verbatim from the Python 3.5 standard
library (http.cookies._unquote) so we don't have to depend on
non-public interfaces.
"""
# If there aren't any doublequotes,
# then there ca... | [
"def",
"_unquote_cookie",
"(",
"s",
":",
"str",
")",
"->",
"str",
":",
"# If there aren't any doublequotes,",
"# then there can't be any special characters. See RFC 2109.",
"if",
"s",
"is",
"None",
"or",
"len",
"(",
"s",
")",
"<",
"2",
":",
"return",
"s",
"if",
... | Handle double quotes and escaping in cookie values.
This method is copied verbatim from the Python 3.5 standard
library (http.cookies._unquote) so we don't have to depend on
non-public interfaces. | [
"Handle",
"double",
"quotes",
"and",
"escaping",
"in",
"cookie",
"values",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L1071-L1118 |
26,777 | tornadoweb/tornado | tornado/httputil.py | HTTPHeaders.get_list | def get_list(self, name: str) -> List[str]:
"""Returns all values for the given header as a list."""
norm_name = _normalized_headers[name]
return self._as_list.get(norm_name, []) | python | def get_list(self, name: str) -> List[str]:
"""Returns all values for the given header as a list."""
norm_name = _normalized_headers[name]
return self._as_list.get(norm_name, []) | [
"def",
"get_list",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"norm_name",
"=",
"_normalized_headers",
"[",
"name",
"]",
"return",
"self",
".",
"_as_list",
".",
"get",
"(",
"norm_name",
",",
"[",
"]",
")"
] | Returns all values for the given header as a list. | [
"Returns",
"all",
"values",
"for",
"the",
"given",
"header",
"as",
"a",
"list",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L174-L177 |
26,778 | tornadoweb/tornado | tornado/httputil.py | HTTPHeaders.parse_line | def parse_line(self, line: str) -> None:
"""Updates the dictionary with a single header line.
>>> h = HTTPHeaders()
>>> h.parse_line("Content-Type: text/html")
>>> h.get('content-type')
'text/html'
"""
if line[0].isspace():
# continuation of a multi-l... | python | def parse_line(self, line: str) -> None:
"""Updates the dictionary with a single header line.
>>> h = HTTPHeaders()
>>> h.parse_line("Content-Type: text/html")
>>> h.get('content-type')
'text/html'
"""
if line[0].isspace():
# continuation of a multi-l... | [
"def",
"parse_line",
"(",
"self",
",",
"line",
":",
"str",
")",
"->",
"None",
":",
"if",
"line",
"[",
"0",
"]",
".",
"isspace",
"(",
")",
":",
"# continuation of a multi-line header",
"if",
"self",
".",
"_last_key",
"is",
"None",
":",
"raise",
"HTTPInput... | Updates the dictionary with a single header line.
>>> h = HTTPHeaders()
>>> h.parse_line("Content-Type: text/html")
>>> h.get('content-type')
'text/html' | [
"Updates",
"the",
"dictionary",
"with",
"a",
"single",
"header",
"line",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L189-L209 |
26,779 | tornadoweb/tornado | tornado/httputil.py | HTTPHeaders.parse | def parse(cls, headers: str) -> "HTTPHeaders":
"""Returns a dictionary from HTTP header text.
>>> h = HTTPHeaders.parse("Content-Type: text/html\\r\\nContent-Length: 42\\r\\n")
>>> sorted(h.items())
[('Content-Length', '42'), ('Content-Type', 'text/html')]
.. versionchanged:: 5... | python | def parse(cls, headers: str) -> "HTTPHeaders":
"""Returns a dictionary from HTTP header text.
>>> h = HTTPHeaders.parse("Content-Type: text/html\\r\\nContent-Length: 42\\r\\n")
>>> sorted(h.items())
[('Content-Length', '42'), ('Content-Type', 'text/html')]
.. versionchanged:: 5... | [
"def",
"parse",
"(",
"cls",
",",
"headers",
":",
"str",
")",
"->",
"\"HTTPHeaders\"",
":",
"h",
"=",
"cls",
"(",
")",
"for",
"line",
"in",
"_CRLF_RE",
".",
"split",
"(",
"headers",
")",
":",
"if",
"line",
":",
"h",
".",
"parse_line",
"(",
"line",
... | Returns a dictionary from HTTP header text.
>>> h = HTTPHeaders.parse("Content-Type: text/html\\r\\nContent-Length: 42\\r\\n")
>>> sorted(h.items())
[('Content-Length', '42'), ('Content-Type', 'text/html')]
.. versionchanged:: 5.1
Raises `HTTPInputError` on malformed header... | [
"Returns",
"a",
"dictionary",
"from",
"HTTP",
"header",
"text",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L212-L229 |
26,780 | tornadoweb/tornado | tornado/httputil.py | HTTPServerRequest.cookies | def cookies(self) -> Dict[str, http.cookies.Morsel]:
"""A dictionary of ``http.cookies.Morsel`` objects."""
if not hasattr(self, "_cookies"):
self._cookies = http.cookies.SimpleCookie()
if "Cookie" in self.headers:
try:
parsed = parse_cookie(se... | python | def cookies(self) -> Dict[str, http.cookies.Morsel]:
"""A dictionary of ``http.cookies.Morsel`` objects."""
if not hasattr(self, "_cookies"):
self._cookies = http.cookies.SimpleCookie()
if "Cookie" in self.headers:
try:
parsed = parse_cookie(se... | [
"def",
"cookies",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"http",
".",
"cookies",
".",
"Morsel",
"]",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_cookies\"",
")",
":",
"self",
".",
"_cookies",
"=",
"http",
".",
"cookies",
".",
"Simp... | A dictionary of ``http.cookies.Morsel`` objects. | [
"A",
"dictionary",
"of",
"http",
".",
"cookies",
".",
"Morsel",
"objects",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L410-L428 |
26,781 | tornadoweb/tornado | tornado/httputil.py | HTTPServerRequest.request_time | def request_time(self) -> float:
"""Returns the amount of time it took for this request to execute."""
if self._finish_time is None:
return time.time() - self._start_time
else:
return self._finish_time - self._start_time | python | def request_time(self) -> float:
"""Returns the amount of time it took for this request to execute."""
if self._finish_time is None:
return time.time() - self._start_time
else:
return self._finish_time - self._start_time | [
"def",
"request_time",
"(",
"self",
")",
"->",
"float",
":",
"if",
"self",
".",
"_finish_time",
"is",
"None",
":",
"return",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"_start_time",
"else",
":",
"return",
"self",
".",
"_finish_time",
"-",
"self"... | Returns the amount of time it took for this request to execute. | [
"Returns",
"the",
"amount",
"of",
"time",
"it",
"took",
"for",
"this",
"request",
"to",
"execute",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L434-L439 |
26,782 | tornadoweb/tornado | tornado/httputil.py | HTTPServerRequest.get_ssl_certificate | def get_ssl_certificate(
self, binary_form: bool = False
) -> Union[None, Dict, bytes]:
"""Returns the client's SSL certificate, if any.
To use client certificates, the HTTPServer's
`ssl.SSLContext.verify_mode` field must be set, e.g.::
ssl_ctx = ssl.create_default_cont... | python | def get_ssl_certificate(
self, binary_form: bool = False
) -> Union[None, Dict, bytes]:
"""Returns the client's SSL certificate, if any.
To use client certificates, the HTTPServer's
`ssl.SSLContext.verify_mode` field must be set, e.g.::
ssl_ctx = ssl.create_default_cont... | [
"def",
"get_ssl_certificate",
"(",
"self",
",",
"binary_form",
":",
"bool",
"=",
"False",
")",
"->",
"Union",
"[",
"None",
",",
"Dict",
",",
"bytes",
"]",
":",
"try",
":",
"if",
"self",
".",
"connection",
"is",
"None",
":",
"return",
"None",
"# TODO: a... | Returns the client's SSL certificate, if any.
To use client certificates, the HTTPServer's
`ssl.SSLContext.verify_mode` field must be set, e.g.::
ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_ctx.load_cert_chain("foo.crt", "foo.key")
ssl_ctx.load... | [
"Returns",
"the",
"client",
"s",
"SSL",
"certificate",
"if",
"any",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L441-L470 |
26,783 | tornadoweb/tornado | tornado/netutil.py | add_accept_handler | def add_accept_handler(
sock: socket.socket, callback: Callable[[socket.socket, Any], None]
) -> Callable[[], None]:
"""Adds an `.IOLoop` event handler to accept new connections on ``sock``.
When a connection is accepted, ``callback(connection, address)`` will
be run (``connection`` is a socket object,... | python | def add_accept_handler(
sock: socket.socket, callback: Callable[[socket.socket, Any], None]
) -> Callable[[], None]:
"""Adds an `.IOLoop` event handler to accept new connections on ``sock``.
When a connection is accepted, ``callback(connection, address)`` will
be run (``connection`` is a socket object,... | [
"def",
"add_accept_handler",
"(",
"sock",
":",
"socket",
".",
"socket",
",",
"callback",
":",
"Callable",
"[",
"[",
"socket",
".",
"socket",
",",
"Any",
"]",
",",
"None",
"]",
")",
"->",
"Callable",
"[",
"[",
"]",
",",
"None",
"]",
":",
"io_loop",
... | Adds an `.IOLoop` event handler to accept new connections on ``sock``.
When a connection is accepted, ``callback(connection, address)`` will
be run (``connection`` is a socket object, and ``address`` is the
address of the other end of the connection). Note that this signature
is different from the ``c... | [
"Adds",
"an",
".",
"IOLoop",
"event",
"handler",
"to",
"accept",
"new",
"connections",
"on",
"sock",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/netutil.py#L220-L280 |
26,784 | tornadoweb/tornado | tornado/netutil.py | is_valid_ip | def is_valid_ip(ip: str) -> bool:
"""Returns ``True`` if the given string is a well-formed IP address.
Supports IPv4 and IPv6.
"""
if not ip or "\x00" in ip:
# getaddrinfo resolves empty strings to localhost, and truncates
# on zero bytes.
return False
try:
res = soc... | python | def is_valid_ip(ip: str) -> bool:
"""Returns ``True`` if the given string is a well-formed IP address.
Supports IPv4 and IPv6.
"""
if not ip or "\x00" in ip:
# getaddrinfo resolves empty strings to localhost, and truncates
# on zero bytes.
return False
try:
res = soc... | [
"def",
"is_valid_ip",
"(",
"ip",
":",
"str",
")",
"->",
"bool",
":",
"if",
"not",
"ip",
"or",
"\"\\x00\"",
"in",
"ip",
":",
"# getaddrinfo resolves empty strings to localhost, and truncates",
"# on zero bytes.",
"return",
"False",
"try",
":",
"res",
"=",
"socket",... | Returns ``True`` if the given string is a well-formed IP address.
Supports IPv4 and IPv6. | [
"Returns",
"True",
"if",
"the",
"given",
"string",
"is",
"a",
"well",
"-",
"formed",
"IP",
"address",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/netutil.py#L283-L301 |
26,785 | tornadoweb/tornado | tornado/netutil.py | ssl_options_to_context | def ssl_options_to_context(
ssl_options: Union[Dict[str, Any], ssl.SSLContext]
) -> ssl.SSLContext:
"""Try to convert an ``ssl_options`` dictionary to an
`~ssl.SSLContext` object.
The ``ssl_options`` dictionary contains keywords to be passed to
`ssl.wrap_socket`. In Python 2.7.9+, `ssl.SSLContext`... | python | def ssl_options_to_context(
ssl_options: Union[Dict[str, Any], ssl.SSLContext]
) -> ssl.SSLContext:
"""Try to convert an ``ssl_options`` dictionary to an
`~ssl.SSLContext` object.
The ``ssl_options`` dictionary contains keywords to be passed to
`ssl.wrap_socket`. In Python 2.7.9+, `ssl.SSLContext`... | [
"def",
"ssl_options_to_context",
"(",
"ssl_options",
":",
"Union",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"ssl",
".",
"SSLContext",
"]",
")",
"->",
"ssl",
".",
"SSLContext",
":",
"if",
"isinstance",
"(",
"ssl_options",
",",
"ssl",
".",
"SSLContex... | Try to convert an ``ssl_options`` dictionary to an
`~ssl.SSLContext` object.
The ``ssl_options`` dictionary contains keywords to be passed to
`ssl.wrap_socket`. In Python 2.7.9+, `ssl.SSLContext` objects can
be used instead. This function converts the dict form to its
`~ssl.SSLContext` equivalent... | [
"Try",
"to",
"convert",
"an",
"ssl_options",
"dictionary",
"to",
"an",
"~ssl",
".",
"SSLContext",
"object",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/netutil.py#L552-L588 |
26,786 | tornadoweb/tornado | tornado/netutil.py | ssl_wrap_socket | def ssl_wrap_socket(
socket: socket.socket,
ssl_options: Union[Dict[str, Any], ssl.SSLContext],
server_hostname: str = None,
**kwargs: Any
) -> ssl.SSLSocket:
"""Returns an ``ssl.SSLSocket`` wrapping the given socket.
``ssl_options`` may be either an `ssl.SSLContext` object or a
dictionary ... | python | def ssl_wrap_socket(
socket: socket.socket,
ssl_options: Union[Dict[str, Any], ssl.SSLContext],
server_hostname: str = None,
**kwargs: Any
) -> ssl.SSLSocket:
"""Returns an ``ssl.SSLSocket`` wrapping the given socket.
``ssl_options`` may be either an `ssl.SSLContext` object or a
dictionary ... | [
"def",
"ssl_wrap_socket",
"(",
"socket",
":",
"socket",
".",
"socket",
",",
"ssl_options",
":",
"Union",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"ssl",
".",
"SSLContext",
"]",
",",
"server_hostname",
":",
"str",
"=",
"None",
",",
"*",
"*",
"kw... | Returns an ``ssl.SSLSocket`` wrapping the given socket.
``ssl_options`` may be either an `ssl.SSLContext` object or a
dictionary (as accepted by `ssl_options_to_context`). Additional
keyword arguments are passed to ``wrap_socket`` (either the
`~ssl.SSLContext` method or the `ssl` module function as
... | [
"Returns",
"an",
"ssl",
".",
"SSLSocket",
"wrapping",
"the",
"given",
"socket",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/netutil.py#L591-L614 |
26,787 | tornadoweb/tornado | tornado/concurrent.py | future_set_exception_unless_cancelled | def future_set_exception_unless_cancelled(
future: "Union[futures.Future[_T], Future[_T]]", exc: BaseException
) -> None:
"""Set the given ``exc`` as the `Future`'s exception.
If the Future is already canceled, logs the exception instead. If
this logging is not desired, the caller should explicitly che... | python | def future_set_exception_unless_cancelled(
future: "Union[futures.Future[_T], Future[_T]]", exc: BaseException
) -> None:
"""Set the given ``exc`` as the `Future`'s exception.
If the Future is already canceled, logs the exception instead. If
this logging is not desired, the caller should explicitly che... | [
"def",
"future_set_exception_unless_cancelled",
"(",
"future",
":",
"\"Union[futures.Future[_T], Future[_T]]\"",
",",
"exc",
":",
"BaseException",
")",
"->",
"None",
":",
"if",
"not",
"future",
".",
"cancelled",
"(",
")",
":",
"future",
".",
"set_exception",
"(",
... | Set the given ``exc`` as the `Future`'s exception.
If the Future is already canceled, logs the exception instead. If
this logging is not desired, the caller should explicitly check
the state of the Future and call ``Future.set_exception`` instead of
this wrapper.
Avoids ``asyncio.InvalidStateError... | [
"Set",
"the",
"given",
"exc",
"as",
"the",
"Future",
"s",
"exception",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/concurrent.py#L188-L207 |
26,788 | tornadoweb/tornado | tornado/concurrent.py | future_set_exc_info | def future_set_exc_info(
future: "Union[futures.Future[_T], Future[_T]]",
exc_info: Tuple[
Optional[type], Optional[BaseException], Optional[types.TracebackType]
],
) -> None:
"""Set the given ``exc_info`` as the `Future`'s exception.
Understands both `asyncio.Future` and the extensions in ... | python | def future_set_exc_info(
future: "Union[futures.Future[_T], Future[_T]]",
exc_info: Tuple[
Optional[type], Optional[BaseException], Optional[types.TracebackType]
],
) -> None:
"""Set the given ``exc_info`` as the `Future`'s exception.
Understands both `asyncio.Future` and the extensions in ... | [
"def",
"future_set_exc_info",
"(",
"future",
":",
"\"Union[futures.Future[_T], Future[_T]]\"",
",",
"exc_info",
":",
"Tuple",
"[",
"Optional",
"[",
"type",
"]",
",",
"Optional",
"[",
"BaseException",
"]",
",",
"Optional",
"[",
"types",
".",
"TracebackType",
"]",
... | Set the given ``exc_info`` as the `Future`'s exception.
Understands both `asyncio.Future` and the extensions in older
versions of Tornado to enable better tracebacks on Python 2.
.. versionadded:: 5.0
.. versionchanged:: 6.0
If the future is already cancelled, this function is a no-op.
... | [
"Set",
"the",
"given",
"exc_info",
"as",
"the",
"Future",
"s",
"exception",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/concurrent.py#L210-L231 |
26,789 | tornadoweb/tornado | tornado/concurrent.py | future_add_done_callback | def future_add_done_callback( # noqa: F811
future: "Union[futures.Future[_T], Future[_T]]", callback: Callable[..., None]
) -> None:
"""Arrange to call ``callback`` when ``future`` is complete.
``callback`` is invoked with one argument, the ``future``.
If ``future`` is already done, ``callback`` is i... | python | def future_add_done_callback( # noqa: F811
future: "Union[futures.Future[_T], Future[_T]]", callback: Callable[..., None]
) -> None:
"""Arrange to call ``callback`` when ``future`` is complete.
``callback`` is invoked with one argument, the ``future``.
If ``future`` is already done, ``callback`` is i... | [
"def",
"future_add_done_callback",
"(",
"# noqa: F811",
"future",
":",
"\"Union[futures.Future[_T], Future[_T]]\"",
",",
"callback",
":",
"Callable",
"[",
"...",
",",
"None",
"]",
")",
"->",
"None",
":",
"if",
"future",
".",
"done",
"(",
")",
":",
"callback",
... | Arrange to call ``callback`` when ``future`` is complete.
``callback`` is invoked with one argument, the ``future``.
If ``future`` is already done, ``callback`` is invoked immediately.
This may differ from the behavior of ``Future.add_done_callback``,
which makes no such guarantee.
.. versionadde... | [
"Arrange",
"to",
"call",
"callback",
"when",
"future",
"is",
"complete",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/concurrent.py#L248-L264 |
26,790 | tornadoweb/tornado | tornado/template.py | filter_whitespace | def filter_whitespace(mode: str, text: str) -> str:
"""Transform whitespace in ``text`` according to ``mode``.
Available modes are:
* ``all``: Return all whitespace unmodified.
* ``single``: Collapse consecutive whitespace with a single whitespace
character, preserving newlines.
* ``oneline`... | python | def filter_whitespace(mode: str, text: str) -> str:
"""Transform whitespace in ``text`` according to ``mode``.
Available modes are:
* ``all``: Return all whitespace unmodified.
* ``single``: Collapse consecutive whitespace with a single whitespace
character, preserving newlines.
* ``oneline`... | [
"def",
"filter_whitespace",
"(",
"mode",
":",
"str",
",",
"text",
":",
"str",
")",
"->",
"str",
":",
"if",
"mode",
"==",
"\"all\"",
":",
"return",
"text",
"elif",
"mode",
"==",
"\"single\"",
":",
"text",
"=",
"re",
".",
"sub",
"(",
"r\"([\\t ]+)\"",
... | Transform whitespace in ``text`` according to ``mode``.
Available modes are:
* ``all``: Return all whitespace unmodified.
* ``single``: Collapse consecutive whitespace with a single whitespace
character, preserving newlines.
* ``oneline``: Collapse all runs of whitespace into a single space
... | [
"Transform",
"whitespace",
"in",
"text",
"according",
"to",
"mode",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/template.py#L226-L248 |
26,791 | tornadoweb/tornado | tornado/iostream.py | _StreamBuffer.advance | def advance(self, size: int) -> None:
"""
Advance the current buffer position by ``size`` bytes.
"""
assert 0 < size <= self._size
self._size -= size
pos = self._first_pos
buffers = self._buffers
while buffers and size > 0:
is_large, b = buffe... | python | def advance(self, size: int) -> None:
"""
Advance the current buffer position by ``size`` bytes.
"""
assert 0 < size <= self._size
self._size -= size
pos = self._first_pos
buffers = self._buffers
while buffers and size > 0:
is_large, b = buffe... | [
"def",
"advance",
"(",
"self",
",",
"size",
":",
"int",
")",
"->",
"None",
":",
"assert",
"0",
"<",
"size",
"<=",
"self",
".",
"_size",
"self",
".",
"_size",
"-=",
"size",
"pos",
"=",
"self",
".",
"_first_pos",
"buffers",
"=",
"self",
".",
"_buffer... | Advance the current buffer position by ``size`` bytes. | [
"Advance",
"the",
"current",
"buffer",
"position",
"by",
"size",
"bytes",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L198-L226 |
26,792 | tornadoweb/tornado | tornado/iostream.py | BaseIOStream.read_until_regex | def read_until_regex(self, regex: bytes, max_bytes: int = None) -> Awaitable[bytes]:
"""Asynchronously read until we have matched the given regex.
The result includes the data that matches the regex and anything
that came before it.
If ``max_bytes`` is not None, the connection will be ... | python | def read_until_regex(self, regex: bytes, max_bytes: int = None) -> Awaitable[bytes]:
"""Asynchronously read until we have matched the given regex.
The result includes the data that matches the regex and anything
that came before it.
If ``max_bytes`` is not None, the connection will be ... | [
"def",
"read_until_regex",
"(",
"self",
",",
"regex",
":",
"bytes",
",",
"max_bytes",
":",
"int",
"=",
"None",
")",
"->",
"Awaitable",
"[",
"bytes",
"]",
":",
"future",
"=",
"self",
".",
"_start_read",
"(",
")",
"self",
".",
"_read_regex",
"=",
"re",
... | Asynchronously read until we have matched the given regex.
The result includes the data that matches the regex and anything
that came before it.
If ``max_bytes`` is not None, the connection will be closed
if more than ``max_bytes`` bytes have been read and the regex is
not sati... | [
"Asynchronously",
"read",
"until",
"we",
"have",
"matched",
"the",
"given",
"regex",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L349-L384 |
26,793 | tornadoweb/tornado | tornado/iostream.py | BaseIOStream.read_until | def read_until(self, delimiter: bytes, max_bytes: int = None) -> Awaitable[bytes]:
"""Asynchronously read until we have found the given delimiter.
The result includes all the data read including the delimiter.
If ``max_bytes`` is not None, the connection will be closed
if more than ``m... | python | def read_until(self, delimiter: bytes, max_bytes: int = None) -> Awaitable[bytes]:
"""Asynchronously read until we have found the given delimiter.
The result includes all the data read including the delimiter.
If ``max_bytes`` is not None, the connection will be closed
if more than ``m... | [
"def",
"read_until",
"(",
"self",
",",
"delimiter",
":",
"bytes",
",",
"max_bytes",
":",
"int",
"=",
"None",
")",
"->",
"Awaitable",
"[",
"bytes",
"]",
":",
"future",
"=",
"self",
".",
"_start_read",
"(",
")",
"self",
".",
"_read_delimiter",
"=",
"deli... | Asynchronously read until we have found the given delimiter.
The result includes all the data read including the delimiter.
If ``max_bytes`` is not None, the connection will be closed
if more than ``max_bytes`` bytes have been read and the delimiter
is not found.
.. versioncha... | [
"Asynchronously",
"read",
"until",
"we",
"have",
"found",
"the",
"given",
"delimiter",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L386-L417 |
26,794 | tornadoweb/tornado | tornado/iostream.py | BaseIOStream.read_until_close | def read_until_close(self) -> Awaitable[bytes]:
"""Asynchronously reads all data from the socket until it is closed.
This will buffer all available data until ``max_buffer_size``
is reached. If flow control or cancellation are desired, use a
loop with `read_bytes(partial=True) <.read_by... | python | def read_until_close(self) -> Awaitable[bytes]:
"""Asynchronously reads all data from the socket until it is closed.
This will buffer all available data until ``max_buffer_size``
is reached. If flow control or cancellation are desired, use a
loop with `read_bytes(partial=True) <.read_by... | [
"def",
"read_until_close",
"(",
"self",
")",
"->",
"Awaitable",
"[",
"bytes",
"]",
":",
"future",
"=",
"self",
".",
"_start_read",
"(",
")",
"if",
"self",
".",
"closed",
"(",
")",
":",
"self",
".",
"_finish_read",
"(",
"self",
".",
"_read_buffer_size",
... | Asynchronously reads all data from the socket until it is closed.
This will buffer all available data until ``max_buffer_size``
is reached. If flow control or cancellation are desired, use a
loop with `read_bytes(partial=True) <.read_bytes>` instead.
.. versionchanged:: 4.0
... | [
"Asynchronously",
"reads",
"all",
"data",
"from",
"the",
"socket",
"until",
"it",
"is",
"closed",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L496-L524 |
26,795 | tornadoweb/tornado | tornado/iostream.py | BaseIOStream.write | def write(self, data: Union[bytes, memoryview]) -> "Future[None]":
"""Asynchronously write the given data to this stream.
This method returns a `.Future` that resolves (with a result
of ``None``) when the write has been completed.
The ``data`` argument may be of type `bytes` or `memory... | python | def write(self, data: Union[bytes, memoryview]) -> "Future[None]":
"""Asynchronously write the given data to this stream.
This method returns a `.Future` that resolves (with a result
of ``None``) when the write has been completed.
The ``data`` argument may be of type `bytes` or `memory... | [
"def",
"write",
"(",
"self",
",",
"data",
":",
"Union",
"[",
"bytes",
",",
"memoryview",
"]",
")",
"->",
"\"Future[None]\"",
":",
"self",
".",
"_check_closed",
"(",
")",
"if",
"data",
":",
"if",
"(",
"self",
".",
"max_write_buffer_size",
"is",
"not",
"... | Asynchronously write the given data to this stream.
This method returns a `.Future` that resolves (with a result
of ``None``) when the write has been completed.
The ``data`` argument may be of type `bytes` or `memoryview`.
.. versionchanged:: 4.0
Now returns a `.Future` if... | [
"Asynchronously",
"write",
"the",
"given",
"data",
"to",
"this",
"stream",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L526-L563 |
26,796 | tornadoweb/tornado | tornado/iostream.py | BaseIOStream.set_close_callback | def set_close_callback(self, callback: Optional[Callable[[], None]]) -> None:
"""Call the given callback when the stream is closed.
This mostly is not necessary for applications that use the
`.Future` interface; all outstanding ``Futures`` will resolve
with a `StreamClosedError` when th... | python | def set_close_callback(self, callback: Optional[Callable[[], None]]) -> None:
"""Call the given callback when the stream is closed.
This mostly is not necessary for applications that use the
`.Future` interface; all outstanding ``Futures`` will resolve
with a `StreamClosedError` when th... | [
"def",
"set_close_callback",
"(",
"self",
",",
"callback",
":",
"Optional",
"[",
"Callable",
"[",
"[",
"]",
",",
"None",
"]",
"]",
")",
"->",
"None",
":",
"self",
".",
"_close_callback",
"=",
"callback",
"self",
".",
"_maybe_add_error_listener",
"(",
")"
] | Call the given callback when the stream is closed.
This mostly is not necessary for applications that use the
`.Future` interface; all outstanding ``Futures`` will resolve
with a `StreamClosedError` when the stream is closed. However,
it is still useful as a way to signal that the strea... | [
"Call",
"the",
"given",
"callback",
"when",
"the",
"stream",
"is",
"closed",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L565-L578 |
26,797 | tornadoweb/tornado | tornado/iostream.py | BaseIOStream.close | def close(
self,
exc_info: Union[
None,
bool,
BaseException,
Tuple[
"Optional[Type[BaseException]]",
Optional[BaseException],
Optional[TracebackType],
],
] = False,
) -> None:
... | python | def close(
self,
exc_info: Union[
None,
bool,
BaseException,
Tuple[
"Optional[Type[BaseException]]",
Optional[BaseException],
Optional[TracebackType],
],
] = False,
) -> None:
... | [
"def",
"close",
"(",
"self",
",",
"exc_info",
":",
"Union",
"[",
"None",
",",
"bool",
",",
"BaseException",
",",
"Tuple",
"[",
"\"Optional[Type[BaseException]]\"",
",",
"Optional",
"[",
"BaseException",
"]",
",",
"Optional",
"[",
"TracebackType",
"]",
",",
"... | Close this stream.
If ``exc_info`` is true, set the ``error`` attribute to the current
exception from `sys.exc_info` (or if ``exc_info`` is a tuple,
use that instead of `sys.exc_info`). | [
"Close",
"this",
"stream",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L580-L617 |
26,798 | tornadoweb/tornado | tornado/iostream.py | BaseIOStream._try_inline_read | def _try_inline_read(self) -> None:
"""Attempt to complete the current read operation from buffered data.
If the read can be completed without blocking, schedules the
read callback on the next IOLoop iteration; otherwise starts
listening for reads on the socket.
"""
# Se... | python | def _try_inline_read(self) -> None:
"""Attempt to complete the current read operation from buffered data.
If the read can be completed without blocking, schedules the
read callback on the next IOLoop iteration; otherwise starts
listening for reads on the socket.
"""
# Se... | [
"def",
"_try_inline_read",
"(",
"self",
")",
"->",
"None",
":",
"# See if we've already got the data from a previous read",
"pos",
"=",
"self",
".",
"_find_read_pos",
"(",
")",
"if",
"pos",
"is",
"not",
"None",
":",
"self",
".",
"_read_from_buffer",
"(",
"pos",
... | Attempt to complete the current read operation from buffered data.
If the read can be completed without blocking, schedules the
read callback on the next IOLoop iteration; otherwise starts
listening for reads on the socket. | [
"Attempt",
"to",
"complete",
"the",
"current",
"read",
"operation",
"from",
"buffered",
"data",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L817-L837 |
26,799 | tornadoweb/tornado | tornado/iostream.py | BaseIOStream._read_to_buffer | def _read_to_buffer(self) -> Optional[int]:
"""Reads from the socket and appends the result to the read buffer.
Returns the number of bytes read. Returns 0 if there is nothing
to read (i.e. the read returns EWOULDBLOCK or equivalent). On
error closes the socket and raises an exception... | python | def _read_to_buffer(self) -> Optional[int]:
"""Reads from the socket and appends the result to the read buffer.
Returns the number of bytes read. Returns 0 if there is nothing
to read (i.e. the read returns EWOULDBLOCK or equivalent). On
error closes the socket and raises an exception... | [
"def",
"_read_to_buffer",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"try",
":",
"while",
"True",
":",
"try",
":",
"if",
"self",
".",
"_user_read_buffer",
":",
"buf",
"=",
"memoryview",
"(",
"self",
".",
"_read_buffer",
")",
"[",
"self",... | Reads from the socket and appends the result to the read buffer.
Returns the number of bytes read. Returns 0 if there is nothing
to read (i.e. the read returns EWOULDBLOCK or equivalent). On
error closes the socket and raises an exception. | [
"Reads",
"from",
"the",
"socket",
"and",
"appends",
"the",
"result",
"to",
"the",
"read",
"buffer",
"."
] | b8b481770bcdb333a69afde5cce7eaa449128326 | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L839-L885 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.