repo
stringclasses
85 values
path
stringlengths
8
121
func_name
stringlengths
1
82
original_string
stringlengths
112
65.5k
language
stringclasses
1 value
code
stringlengths
112
65.5k
code_tokens
listlengths
20
4.09k
docstring
stringlengths
3
46.3k
docstring_tokens
listlengths
1
564
sha
stringclasses
85 values
url
stringlengths
93
218
partition
stringclasses
1 value
tornadoweb/tornado
tornado/queues.py
Queue.get_nowait
def get_nowait(self) -> _T: """Remove and return an item from the queue without blocking. Return an item if one is immediately available, else raise `QueueEmpty`. """ self._consume_expired() if self._putters: assert self.full(), "queue not full, why are putte...
python
def get_nowait(self) -> _T: """Remove and return an item from the queue without blocking. Return an item if one is immediately available, else raise `QueueEmpty`. """ self._consume_expired() if self._putters: assert self.full(), "queue not full, why are putte...
[ "def", "get_nowait", "(", "self", ")", "->", "_T", ":", "self", ".", "_consume_expired", "(", ")", "if", "self", ".", "_putters", ":", "assert", "self", ".", "full", "(", ")", ",", "\"queue not full, why are putters waiting?\"", "item", ",", "putter", "=", ...
Remove and return an item from the queue without blocking. Return an item if one is immediately available, else raise `QueueEmpty`.
[ "Remove", "and", "return", "an", "item", "from", "the", "queue", "without", "blocking", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L254-L270
train
tornadoweb/tornado
tornado/queues.py
Queue.task_done
def task_done(self) -> None: """Indicate that a formerly enqueued task is complete. Used by queue consumers. For each `.get` used to fetch a task, a subsequent call to `.task_done` tells the queue that the processing on the task is complete. If a `.join` is blocking, it resumes...
python
def task_done(self) -> None: """Indicate that a formerly enqueued task is complete. Used by queue consumers. For each `.get` used to fetch a task, a subsequent call to `.task_done` tells the queue that the processing on the task is complete. If a `.join` is blocking, it resumes...
[ "def", "task_done", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_unfinished_tasks", "<=", "0", ":", "raise", "ValueError", "(", "\"task_done() called too many times\"", ")", "self", ".", "_unfinished_tasks", "-=", "1", "if", "self", ".", "_unfinis...
Indicate that a formerly enqueued task is complete. Used by queue consumers. For each `.get` used to fetch a task, a subsequent call to `.task_done` tells the queue that the processing on the task is complete. If a `.join` is blocking, it resumes when all items have been proces...
[ "Indicate", "that", "a", "formerly", "enqueued", "task", "is", "complete", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L272-L288
train
tornadoweb/tornado
tornado/queues.py
Queue.join
def join(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[None]: """Block until all items in the queue are processed. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ return self._finished.wait(timeout)
python
def join(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[None]: """Block until all items in the queue are processed. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ return self._finished.wait(timeout)
[ "def", "join", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "None", "]", ":", "return", "self", ".", "_finished", ".", "wait", "(", "timeout", ")" ]
Block until all items in the queue are processed. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout.
[ "Block", "until", "all", "items", "in", "the", "queue", "are", "processed", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L290-L296
train
tornadoweb/tornado
tornado/process.py
cpu_count
def cpu_count() -> int: """Returns the number of processors on this machine.""" if multiprocessing is None: return 1 try: return multiprocessing.cpu_count() except NotImplementedError: pass try: return os.sysconf("SC_NPROCESSORS_CONF") except (AttributeError, Valu...
python
def cpu_count() -> int: """Returns the number of processors on this machine.""" if multiprocessing is None: return 1 try: return multiprocessing.cpu_count() except NotImplementedError: pass try: return os.sysconf("SC_NPROCESSORS_CONF") except (AttributeError, Valu...
[ "def", "cpu_count", "(", ")", "->", "int", ":", "if", "multiprocessing", "is", "None", ":", "return", "1", "try", ":", "return", "multiprocessing", ".", "cpu_count", "(", ")", "except", "NotImplementedError", ":", "pass", "try", ":", "return", "os", ".", ...
Returns the number of processors on this machine.
[ "Returns", "the", "number", "of", "processors", "on", "this", "machine", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L51-L64
train
tornadoweb/tornado
tornado/process.py
fork_processes
def fork_processes(num_processes: Optional[int], max_restarts: int = None) -> int: """Starts multiple worker processes. If ``num_processes`` is None or <= 0, we detect the number of cores available on this machine and fork that number of child processes. If ``num_processes`` is given and > 0, we fork t...
python
def fork_processes(num_processes: Optional[int], max_restarts: int = None) -> int: """Starts multiple worker processes. If ``num_processes`` is None or <= 0, we detect the number of cores available on this machine and fork that number of child processes. If ``num_processes`` is given and > 0, we fork t...
[ "def", "fork_processes", "(", "num_processes", ":", "Optional", "[", "int", "]", ",", "max_restarts", ":", "int", "=", "None", ")", "->", "int", ":", "if", "max_restarts", "is", "None", ":", "max_restarts", "=", "100", "global", "_task_id", "assert", "_tas...
Starts multiple worker processes. If ``num_processes`` is None or <= 0, we detect the number of cores available on this machine and fork that number of child processes. If ``num_processes`` is given and > 0, we fork that specific number of sub-processes. Since we use processes and not threads, the...
[ "Starts", "multiple", "worker", "processes", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L92-L185
train
tornadoweb/tornado
tornado/process.py
Subprocess.set_exit_callback
def set_exit_callback(self, callback: Callable[[int], None]) -> None: """Runs ``callback`` when this process exits. The callback takes one argument, the return code of the process. This method uses a ``SIGCHLD`` handler, which is a global setting and may conflict if you have other libr...
python
def set_exit_callback(self, callback: Callable[[int], None]) -> None: """Runs ``callback`` when this process exits. The callback takes one argument, the return code of the process. This method uses a ``SIGCHLD`` handler, which is a global setting and may conflict if you have other libr...
[ "def", "set_exit_callback", "(", "self", ",", "callback", ":", "Callable", "[", "[", "int", "]", ",", "None", "]", ")", "->", "None", ":", "self", ".", "_exit_callback", "=", "callback", "Subprocess", ".", "initialize", "(", ")", "Subprocess", ".", "_wai...
Runs ``callback`` when this process exits. The callback takes one argument, the return code of the process. This method uses a ``SIGCHLD`` handler, which is a global setting and may conflict if you have other libraries trying to handle the same signal. If you are using more than one `...
[ "Runs", "callback", "when", "this", "process", "exits", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L264-L284
train
tornadoweb/tornado
tornado/process.py
Subprocess.wait_for_exit
def wait_for_exit(self, raise_error: bool = True) -> "Future[int]": """Returns a `.Future` which resolves when the process exits. Usage:: ret = yield proc.wait_for_exit() This is a coroutine-friendly alternative to `set_exit_callback` (and a replacement for the blocking `s...
python
def wait_for_exit(self, raise_error: bool = True) -> "Future[int]": """Returns a `.Future` which resolves when the process exits. Usage:: ret = yield proc.wait_for_exit() This is a coroutine-friendly alternative to `set_exit_callback` (and a replacement for the blocking `s...
[ "def", "wait_for_exit", "(", "self", ",", "raise_error", ":", "bool", "=", "True", ")", "->", "\"Future[int]\"", ":", "future", "=", "Future", "(", ")", "# type: Future[int]", "def", "callback", "(", "ret", ":", "int", ")", "->", "None", ":", "if", "ret"...
Returns a `.Future` which resolves when the process exits. Usage:: ret = yield proc.wait_for_exit() This is a coroutine-friendly alternative to `set_exit_callback` (and a replacement for the blocking `subprocess.Popen.wait`). By default, raises `subprocess.CalledProcessEr...
[ "Returns", "a", ".", "Future", "which", "resolves", "when", "the", "process", "exits", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L286-L316
train
tornadoweb/tornado
tornado/process.py
Subprocess.initialize
def initialize(cls) -> None: """Initializes the ``SIGCHLD`` handler. The signal handler is run on an `.IOLoop` to avoid locking issues. Note that the `.IOLoop` used for signal handling need not be the same one used by individual Subprocess objects (as long as the ``IOLoops`` are...
python
def initialize(cls) -> None: """Initializes the ``SIGCHLD`` handler. The signal handler is run on an `.IOLoop` to avoid locking issues. Note that the `.IOLoop` used for signal handling need not be the same one used by individual Subprocess objects (as long as the ``IOLoops`` are...
[ "def", "initialize", "(", "cls", ")", "->", "None", ":", "if", "cls", ".", "_initialized", ":", "return", "io_loop", "=", "ioloop", ".", "IOLoop", ".", "current", "(", ")", "cls", ".", "_old_sigchld", "=", "signal", ".", "signal", "(", "signal", ".", ...
Initializes the ``SIGCHLD`` handler. The signal handler is run on an `.IOLoop` to avoid locking issues. Note that the `.IOLoop` used for signal handling need not be the same one used by individual Subprocess objects (as long as the ``IOLoops`` are each running in separate threads). ...
[ "Initializes", "the", "SIGCHLD", "handler", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L319-L340
train
tornadoweb/tornado
tornado/process.py
Subprocess.uninitialize
def uninitialize(cls) -> None: """Removes the ``SIGCHLD`` handler.""" if not cls._initialized: return signal.signal(signal.SIGCHLD, cls._old_sigchld) cls._initialized = False
python
def uninitialize(cls) -> None: """Removes the ``SIGCHLD`` handler.""" if not cls._initialized: return signal.signal(signal.SIGCHLD, cls._old_sigchld) cls._initialized = False
[ "def", "uninitialize", "(", "cls", ")", "->", "None", ":", "if", "not", "cls", ".", "_initialized", ":", "return", "signal", ".", "signal", "(", "signal", ".", "SIGCHLD", ",", "cls", ".", "_old_sigchld", ")", "cls", ".", "_initialized", "=", "False" ]
Removes the ``SIGCHLD`` handler.
[ "Removes", "the", "SIGCHLD", "handler", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L343-L348
train
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._handle_socket
def _handle_socket(self, event: int, fd: int, multi: Any, data: bytes) -> None: """Called by libcurl when it wants to change the file descriptors it cares about. """ event_map = { pycurl.POLL_NONE: ioloop.IOLoop.NONE, pycurl.POLL_IN: ioloop.IOLoop.READ, ...
python
def _handle_socket(self, event: int, fd: int, multi: Any, data: bytes) -> None: """Called by libcurl when it wants to change the file descriptors it cares about. """ event_map = { pycurl.POLL_NONE: ioloop.IOLoop.NONE, pycurl.POLL_IN: ioloop.IOLoop.READ, ...
[ "def", "_handle_socket", "(", "self", ",", "event", ":", "int", ",", "fd", ":", "int", ",", "multi", ":", "Any", ",", "data", ":", "bytes", ")", "->", "None", ":", "event_map", "=", "{", "pycurl", ".", "POLL_NONE", ":", "ioloop", ".", "IOLoop", "."...
Called by libcurl when it wants to change the file descriptors it cares about.
[ "Called", "by", "libcurl", "when", "it", "wants", "to", "change", "the", "file", "descriptors", "it", "cares", "about", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L104-L131
train
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._set_timeout
def _set_timeout(self, msecs: int) -> None: """Called by libcurl to schedule a timeout.""" if self._timeout is not None: self.io_loop.remove_timeout(self._timeout) self._timeout = self.io_loop.add_timeout( self.io_loop.time() + msecs / 1000.0, self._handle_timeout ...
python
def _set_timeout(self, msecs: int) -> None: """Called by libcurl to schedule a timeout.""" if self._timeout is not None: self.io_loop.remove_timeout(self._timeout) self._timeout = self.io_loop.add_timeout( self.io_loop.time() + msecs / 1000.0, self._handle_timeout ...
[ "def", "_set_timeout", "(", "self", ",", "msecs", ":", "int", ")", "->", "None", ":", "if", "self", ".", "_timeout", "is", "not", "None", ":", "self", ".", "io_loop", ".", "remove_timeout", "(", "self", ".", "_timeout", ")", "self", ".", "_timeout", ...
Called by libcurl to schedule a timeout.
[ "Called", "by", "libcurl", "to", "schedule", "a", "timeout", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L133-L139
train
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._handle_events
def _handle_events(self, fd: int, events: int) -> None: """Called by IOLoop when there is activity on one of our file descriptors. """ action = 0 if events & ioloop.IOLoop.READ: action |= pycurl.CSELECT_IN if events & ioloop.IOLoop.WRITE: action |=...
python
def _handle_events(self, fd: int, events: int) -> None: """Called by IOLoop when there is activity on one of our file descriptors. """ action = 0 if events & ioloop.IOLoop.READ: action |= pycurl.CSELECT_IN if events & ioloop.IOLoop.WRITE: action |=...
[ "def", "_handle_events", "(", "self", ",", "fd", ":", "int", ",", "events", ":", "int", ")", "->", "None", ":", "action", "=", "0", "if", "events", "&", "ioloop", ".", "IOLoop", ".", "READ", ":", "action", "|=", "pycurl", ".", "CSELECT_IN", "if", "...
Called by IOLoop when there is activity on one of our file descriptors.
[ "Called", "by", "IOLoop", "when", "there", "is", "activity", "on", "one", "of", "our", "file", "descriptors", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L141-L157
train
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._handle_timeout
def _handle_timeout(self) -> None: """Called by IOLoop when the requested timeout has passed.""" self._timeout = None while True: try: ret, num_handles = self._multi.socket_action(pycurl.SOCKET_TIMEOUT, 0) except pycurl.error as e: ret = e....
python
def _handle_timeout(self) -> None: """Called by IOLoop when the requested timeout has passed.""" self._timeout = None while True: try: ret, num_handles = self._multi.socket_action(pycurl.SOCKET_TIMEOUT, 0) except pycurl.error as e: ret = e....
[ "def", "_handle_timeout", "(", "self", ")", "->", "None", ":", "self", ".", "_timeout", "=", "None", "while", "True", ":", "try", ":", "ret", ",", "num_handles", "=", "self", ".", "_multi", ".", "socket_action", "(", "pycurl", ".", "SOCKET_TIMEOUT", ",",...
Called by IOLoop when the requested timeout has passed.
[ "Called", "by", "IOLoop", "when", "the", "requested", "timeout", "has", "passed", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L159-L186
train
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._handle_force_timeout
def _handle_force_timeout(self) -> None: """Called by IOLoop periodically to ask libcurl to process any events it may have forgotten about. """ while True: try: ret, num_handles = self._multi.socket_all() except pycurl.error as e: r...
python
def _handle_force_timeout(self) -> None: """Called by IOLoop periodically to ask libcurl to process any events it may have forgotten about. """ while True: try: ret, num_handles = self._multi.socket_all() except pycurl.error as e: r...
[ "def", "_handle_force_timeout", "(", "self", ")", "->", "None", ":", "while", "True", ":", "try", ":", "ret", ",", "num_handles", "=", "self", ".", "_multi", ".", "socket_all", "(", ")", "except", "pycurl", ".", "error", "as", "e", ":", "ret", "=", "...
Called by IOLoop periodically to ask libcurl to process any events it may have forgotten about.
[ "Called", "by", "IOLoop", "periodically", "to", "ask", "libcurl", "to", "process", "any", "events", "it", "may", "have", "forgotten", "about", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L188-L199
train
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._finish_pending_requests
def _finish_pending_requests(self) -> None: """Process any requests that were completed by the last call to multi.socket_action. """ while True: num_q, ok_list, err_list = self._multi.info_read() for curl in ok_list: self._finish(curl) ...
python
def _finish_pending_requests(self) -> None: """Process any requests that were completed by the last call to multi.socket_action. """ while True: num_q, ok_list, err_list = self._multi.info_read() for curl in ok_list: self._finish(curl) ...
[ "def", "_finish_pending_requests", "(", "self", ")", "->", "None", ":", "while", "True", ":", "num_q", ",", "ok_list", ",", "err_list", "=", "self", ".", "_multi", ".", "info_read", "(", ")", "for", "curl", "in", "ok_list", ":", "self", ".", "_finish", ...
Process any requests that were completed by the last call to multi.socket_action.
[ "Process", "any", "requests", "that", "were", "completed", "by", "the", "last", "call", "to", "multi", ".", "socket_action", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L201-L213
train
tornadoweb/tornado
demos/s3server/s3server.py
start
def start(port, root_directory, bucket_depth): """Starts the mock S3 server on the given port at the given path.""" application = S3Application(root_directory, bucket_depth) http_server = httpserver.HTTPServer(application) http_server.listen(port) ioloop.IOLoop.current().start()
python
def start(port, root_directory, bucket_depth): """Starts the mock S3 server on the given port at the given path.""" application = S3Application(root_directory, bucket_depth) http_server = httpserver.HTTPServer(application) http_server.listen(port) ioloop.IOLoop.current().start()
[ "def", "start", "(", "port", ",", "root_directory", ",", "bucket_depth", ")", ":", "application", "=", "S3Application", "(", "root_directory", ",", "bucket_depth", ")", "http_server", "=", "httpserver", ".", "HTTPServer", "(", "application", ")", "http_server", ...
Starts the mock S3 server on the given port at the given path.
[ "Starts", "the", "mock", "S3", "server", "on", "the", "given", "port", "at", "the", "given", "path", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/s3server/s3server.py#L57-L62
train
tornadoweb/tornado
tornado/httpclient.py
HTTPClient.close
def close(self) -> None: """Closes the HTTPClient, freeing any resources used.""" if not self._closed: self._async_client.close() self._io_loop.close() self._closed = True
python
def close(self) -> None: """Closes the HTTPClient, freeing any resources used.""" if not self._closed: self._async_client.close() self._io_loop.close() self._closed = True
[ "def", "close", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "_closed", ":", "self", ".", "_async_client", ".", "close", "(", ")", "self", ".", "_io_loop", ".", "close", "(", ")", "self", ".", "_closed", "=", "True" ]
Closes the HTTPClient, freeing any resources used.
[ "Closes", "the", "HTTPClient", "freeing", "any", "resources", "used", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L113-L118
train
tornadoweb/tornado
tornado/httpclient.py
HTTPClient.fetch
def fetch( self, request: Union["HTTPRequest", str], **kwargs: Any ) -> "HTTPResponse": """Executes a request, returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional ...
python
def fetch( self, request: Union["HTTPRequest", str], **kwargs: Any ) -> "HTTPResponse": """Executes a request, returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional ...
[ "def", "fetch", "(", "self", ",", "request", ":", "Union", "[", "\"HTTPRequest\"", ",", "str", "]", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "\"HTTPResponse\"", ":", "response", "=", "self", ".", "_io_loop", ".", "run_sync", "(", "functools", "....
Executes a request, returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional kwargs: ``HTTPRequest(request, **kwargs)`` If an error occurs during the fetch, we raise an `HTTPErr...
[ "Executes", "a", "request", "returning", "an", "HTTPResponse", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L120-L135
train
tornadoweb/tornado
tornado/httpclient.py
AsyncHTTPClient.close
def close(self) -> None: """Destroys this HTTP client, freeing any file descriptors used. This method is **not needed in normal use** due to the way that `AsyncHTTPClient` objects are transparently reused. ``close()`` is generally only necessary when either the `.IOLoop` is also...
python
def close(self) -> None: """Destroys this HTTP client, freeing any file descriptors used. This method is **not needed in normal use** due to the way that `AsyncHTTPClient` objects are transparently reused. ``close()`` is generally only necessary when either the `.IOLoop` is also...
[ "def", "close", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_closed", ":", "return", "self", ".", "_closed", "=", "True", "if", "self", ".", "_instance_cache", "is", "not", "None", ":", "cached_val", "=", "self", ".", "_instance_cache", "....
Destroys this HTTP client, freeing any file descriptors used. This method is **not needed in normal use** due to the way that `AsyncHTTPClient` objects are transparently reused. ``close()`` is generally only necessary when either the `.IOLoop` is also being closed, or the ``force_instan...
[ "Destroys", "this", "HTTP", "client", "freeing", "any", "file", "descriptors", "used", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L221-L245
train
tornadoweb/tornado
tornado/httpclient.py
AsyncHTTPClient.fetch
def fetch( self, request: Union[str, "HTTPRequest"], raise_error: bool = True, **kwargs: Any ) -> Awaitable["HTTPResponse"]: """Executes a request, asynchronously returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. ...
python
def fetch( self, request: Union[str, "HTTPRequest"], raise_error: bool = True, **kwargs: Any ) -> Awaitable["HTTPResponse"]: """Executes a request, asynchronously returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. ...
[ "def", "fetch", "(", "self", ",", "request", ":", "Union", "[", "str", ",", "\"HTTPRequest\"", "]", ",", "raise_error", ":", "bool", "=", "True", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "Awaitable", "[", "\"HTTPResponse\"", "]", ":", "if", "s...
Executes a request, asynchronously returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional kwargs: ``HTTPRequest(request, **kwargs)`` This method returns a `.Future` whose resu...
[ "Executes", "a", "request", "asynchronously", "returning", "an", "HTTPResponse", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L247-L305
train
tornadoweb/tornado
tornado/httpclient.py
AsyncHTTPClient.configure
def configure( cls, impl: "Union[None, str, Type[Configurable]]", **kwargs: Any ) -> None: """Configures the `AsyncHTTPClient` subclass to use. ``AsyncHTTPClient()`` actually creates an instance of a subclass. This method may be called with either a class object or the fully...
python
def configure( cls, impl: "Union[None, str, Type[Configurable]]", **kwargs: Any ) -> None: """Configures the `AsyncHTTPClient` subclass to use. ``AsyncHTTPClient()`` actually creates an instance of a subclass. This method may be called with either a class object or the fully...
[ "def", "configure", "(", "cls", ",", "impl", ":", "\"Union[None, str, Type[Configurable]]\"", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "super", "(", "AsyncHTTPClient", ",", "cls", ")", ".", "configure", "(", "impl", ",", "*", "*", "kw...
Configures the `AsyncHTTPClient` subclass to use. ``AsyncHTTPClient()`` actually creates an instance of a subclass. This method may be called with either a class object or the fully-qualified name of such a class (or ``None`` to use the default, ``SimpleAsyncHTTPClient``) If ad...
[ "Configures", "the", "AsyncHTTPClient", "subclass", "to", "use", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L313-L334
train
aio-libs/aiohttp
aiohttp/connector.py
BaseConnector._cleanup
def _cleanup(self) -> None: """Cleanup unused transports.""" if self._cleanup_handle: self._cleanup_handle.cancel() now = self._loop.time() timeout = self._keepalive_timeout if self._conns: connections = {} deadline = now - timeout ...
python
def _cleanup(self) -> None: """Cleanup unused transports.""" if self._cleanup_handle: self._cleanup_handle.cancel() now = self._loop.time() timeout = self._keepalive_timeout if self._conns: connections = {} deadline = now - timeout ...
[ "def", "_cleanup", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_cleanup_handle", ":", "self", ".", "_cleanup_handle", ".", "cancel", "(", ")", "now", "=", "self", ".", "_loop", ".", "time", "(", ")", "timeout", "=", "self", ".", "_keepal...
Cleanup unused transports.
[ "Cleanup", "unused", "transports", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L327-L359
train
aio-libs/aiohttp
aiohttp/connector.py
BaseConnector._cleanup_closed
def _cleanup_closed(self) -> None: """Double confirmation for transport close. Some broken ssl servers may leave socket open without proper close. """ if self._cleanup_closed_handle: self._cleanup_closed_handle.cancel() for transport in self._cleanup_closed_transport...
python
def _cleanup_closed(self) -> None: """Double confirmation for transport close. Some broken ssl servers may leave socket open without proper close. """ if self._cleanup_closed_handle: self._cleanup_closed_handle.cancel() for transport in self._cleanup_closed_transport...
[ "def", "_cleanup_closed", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_cleanup_closed_handle", ":", "self", ".", "_cleanup_closed_handle", ".", "cancel", "(", ")", "for", "transport", "in", "self", ".", "_cleanup_closed_transports", ":", "if", "tr...
Double confirmation for transport close. Some broken ssl servers may leave socket open without proper close.
[ "Double", "confirmation", "for", "transport", "close", ".", "Some", "broken", "ssl", "servers", "may", "leave", "socket", "open", "without", "proper", "close", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L371-L387
train
aio-libs/aiohttp
aiohttp/connector.py
BaseConnector._available_connections
def _available_connections(self, key: 'ConnectionKey') -> int: """ Return number of available connections taking into account the limit, limit_per_host and the connection key. If it returns less than 1 means that there is no connections availables. """ if self._...
python
def _available_connections(self, key: 'ConnectionKey') -> int: """ Return number of available connections taking into account the limit, limit_per_host and the connection key. If it returns less than 1 means that there is no connections availables. """ if self._...
[ "def", "_available_connections", "(", "self", ",", "key", ":", "'ConnectionKey'", ")", "->", "int", ":", "if", "self", ".", "_limit", ":", "# total calc available connections", "available", "=", "self", ".", "_limit", "-", "len", "(", "self", ".", "_acquired",...
Return number of available connections taking into account the limit, limit_per_host and the connection key. If it returns less than 1 means that there is no connections availables.
[ "Return", "number", "of", "available", "connections", "taking", "into", "account", "the", "limit", "limit_per_host", "and", "the", "connection", "key", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L439-L467
train
aio-libs/aiohttp
aiohttp/connector.py
BaseConnector.connect
async def connect(self, req: 'ClientRequest', traces: List['Trace'], timeout: 'ClientTimeout') -> Connection: """Get from pool or create new connection.""" key = req.connection_key available = self._available_connections(key) # Wait if there a...
python
async def connect(self, req: 'ClientRequest', traces: List['Trace'], timeout: 'ClientTimeout') -> Connection: """Get from pool or create new connection.""" key = req.connection_key available = self._available_connections(key) # Wait if there a...
[ "async", "def", "connect", "(", "self", ",", "req", ":", "'ClientRequest'", ",", "traces", ":", "List", "[", "'Trace'", "]", ",", "timeout", ":", "'ClientTimeout'", ")", "->", "Connection", ":", "key", "=", "req", ".", "connection_key", "available", "=", ...
Get from pool or create new connection.
[ "Get", "from", "pool", "or", "create", "new", "connection", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L469-L547
train
aio-libs/aiohttp
aiohttp/connector.py
BaseConnector._release_waiter
def _release_waiter(self) -> None: """ Iterates over all waiters till found one that is not finsihed and belongs to a host that has available connections. """ if not self._waiters: return # Having the dict keys ordered this avoids to iterate # at the ...
python
def _release_waiter(self) -> None: """ Iterates over all waiters till found one that is not finsihed and belongs to a host that has available connections. """ if not self._waiters: return # Having the dict keys ordered this avoids to iterate # at the ...
[ "def", "_release_waiter", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "_waiters", ":", "return", "# Having the dict keys ordered this avoids to iterate", "# at the same order at each call.", "queues", "=", "list", "(", "self", ".", "_waiters", ".", ...
Iterates over all waiters till found one that is not finsihed and belongs to a host that has available connections.
[ "Iterates", "over", "all", "waiters", "till", "found", "one", "that", "is", "not", "finsihed", "and", "belongs", "to", "a", "host", "that", "has", "available", "connections", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L575-L597
train
aio-libs/aiohttp
aiohttp/connector.py
TCPConnector.close
def close(self) -> Awaitable[None]: """Close all ongoing DNS calls.""" for ev in self._throttle_dns_events.values(): ev.cancel() return super().close()
python
def close(self) -> Awaitable[None]: """Close all ongoing DNS calls.""" for ev in self._throttle_dns_events.values(): ev.cancel() return super().close()
[ "def", "close", "(", "self", ")", "->", "Awaitable", "[", "None", "]", ":", "for", "ev", "in", "self", ".", "_throttle_dns_events", ".", "values", "(", ")", ":", "ev", ".", "cancel", "(", ")", "return", "super", "(", ")", ".", "close", "(", ")" ]
Close all ongoing DNS calls.
[ "Close", "all", "ongoing", "DNS", "calls", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L744-L749
train
aio-libs/aiohttp
aiohttp/connector.py
TCPConnector.clear_dns_cache
def clear_dns_cache(self, host: Optional[str]=None, port: Optional[int]=None) -> None: """Remove specified host/port or clear all dns local cache.""" if host is not None and port is not None: self._cached_hosts.remove((host, port)) elif...
python
def clear_dns_cache(self, host: Optional[str]=None, port: Optional[int]=None) -> None: """Remove specified host/port or clear all dns local cache.""" if host is not None and port is not None: self._cached_hosts.remove((host, port)) elif...
[ "def", "clear_dns_cache", "(", "self", ",", "host", ":", "Optional", "[", "str", "]", "=", "None", ",", "port", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "None", ":", "if", "host", "is", "not", "None", "and", "port", "is", "not", ...
Remove specified host/port or clear all dns local cache.
[ "Remove", "specified", "host", "/", "port", "or", "clear", "all", "dns", "local", "cache", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L761-L771
train
aio-libs/aiohttp
aiohttp/connector.py
TCPConnector._create_connection
async def _create_connection(self, req: 'ClientRequest', traces: List['Trace'], timeout: 'ClientTimeout') -> ResponseHandler: """Create connection. Has same keyword arguments as BaseEventLoop.create_connection. """ if req...
python
async def _create_connection(self, req: 'ClientRequest', traces: List['Trace'], timeout: 'ClientTimeout') -> ResponseHandler: """Create connection. Has same keyword arguments as BaseEventLoop.create_connection. """ if req...
[ "async", "def", "_create_connection", "(", "self", ",", "req", ":", "'ClientRequest'", ",", "traces", ":", "List", "[", "'Trace'", "]", ",", "timeout", ":", "'ClientTimeout'", ")", "->", "ResponseHandler", ":", "if", "req", ".", "proxy", ":", "_", ",", "...
Create connection. Has same keyword arguments as BaseEventLoop.create_connection.
[ "Create", "connection", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L842-L856
train
aio-libs/aiohttp
aiohttp/connector.py
TCPConnector._get_ssl_context
def _get_ssl_context(self, req: 'ClientRequest') -> Optional[SSLContext]: """Logic to get the correct SSL context 0. if req.ssl is false, return None 1. if ssl_context is specified in req, use it 2. if _ssl_context is specified in self, use it 3. otherwise: 1. if ve...
python
def _get_ssl_context(self, req: 'ClientRequest') -> Optional[SSLContext]: """Logic to get the correct SSL context 0. if req.ssl is false, return None 1. if ssl_context is specified in req, use it 2. if _ssl_context is specified in self, use it 3. otherwise: 1. if ve...
[ "def", "_get_ssl_context", "(", "self", ",", "req", ":", "'ClientRequest'", ")", "->", "Optional", "[", "SSLContext", "]", ":", "if", "req", ".", "is_ssl", "(", ")", ":", "if", "ssl", "is", "None", ":", "# pragma: no cover", "raise", "RuntimeError", "(", ...
Logic to get the correct SSL context 0. if req.ssl is false, return None 1. if ssl_context is specified in req, use it 2. if _ssl_context is specified in self, use it 3. otherwise: 1. if verify_ssl is not specified in req, use self.ssl_context (will generate ...
[ "Logic", "to", "get", "the", "correct", "SSL", "context" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L871-L902
train
aio-libs/aiohttp
aiohttp/http_websocket.py
_websocket_mask_python
def _websocket_mask_python(mask: bytes, data: bytearray) -> None: """Websocket masking function. `mask` is a `bytes` object of length 4; `data` is a `bytearray` object of any length. The contents of `data` are masked with `mask`, as specified in section 5.3 of RFC 6455. Note that this function mut...
python
def _websocket_mask_python(mask: bytes, data: bytearray) -> None: """Websocket masking function. `mask` is a `bytes` object of length 4; `data` is a `bytearray` object of any length. The contents of `data` are masked with `mask`, as specified in section 5.3 of RFC 6455. Note that this function mut...
[ "def", "_websocket_mask_python", "(", "mask", ":", "bytes", ",", "data", ":", "bytearray", ")", "->", "None", ":", "assert", "isinstance", "(", "data", ",", "bytearray", ")", ",", "data", "assert", "len", "(", "mask", ")", "==", "4", ",", "mask", "if",...
Websocket masking function. `mask` is a `bytes` object of length 4; `data` is a `bytearray` object of any length. The contents of `data` are masked with `mask`, as specified in section 5.3 of RFC 6455. Note that this function mutates the `data` argument. This pure-python implementation may be rep...
[ "Websocket", "masking", "function", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_websocket.py#L117-L138
train
aio-libs/aiohttp
aiohttp/http_websocket.py
WSMessage.json
def json(self, *, # type: ignore loads: Callable[[Any], Any]=json.loads) -> None: """Return parsed JSON data. .. versionadded:: 0.22 """ return loads(self.data)
python
def json(self, *, # type: ignore loads: Callable[[Any], Any]=json.loads) -> None: """Return parsed JSON data. .. versionadded:: 0.22 """ return loads(self.data)
[ "def", "json", "(", "self", ",", "*", ",", "# type: ignore", "loads", ":", "Callable", "[", "[", "Any", "]", ",", "Any", "]", "=", "json", ".", "loads", ")", "->", "None", ":", "return", "loads", "(", "self", ".", "data", ")" ]
Return parsed JSON data. .. versionadded:: 0.22
[ "Return", "parsed", "JSON", "data", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_websocket.py#L85-L91
train
aio-libs/aiohttp
aiohttp/http_websocket.py
WebSocketReader.parse_frame
def parse_frame(self, buf: bytes) -> List[Tuple[bool, Optional[int], bytearray, Optional[bool]]]: """Return the next frame from the socket.""" frames = [] if self._tail: buf, self....
python
def parse_frame(self, buf: bytes) -> List[Tuple[bool, Optional[int], bytearray, Optional[bool]]]: """Return the next frame from the socket.""" frames = [] if self._tail: buf, self....
[ "def", "parse_frame", "(", "self", ",", "buf", ":", "bytes", ")", "->", "List", "[", "Tuple", "[", "bool", ",", "Optional", "[", "int", "]", ",", "bytearray", ",", "Optional", "[", "bool", "]", "]", "]", ":", "frames", "=", "[", "]", "if", "self"...
Return the next frame from the socket.
[ "Return", "the", "next", "frame", "from", "the", "socket", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_websocket.py#L392-L541
train
aio-libs/aiohttp
aiohttp/http_websocket.py
WebSocketWriter._send_frame
async def _send_frame(self, message: bytes, opcode: int, compress: Optional[int]=None) -> None: """Send a frame over the websocket with message as its payload.""" if self._closing: ws_logger.warning('websocket connection is closing.') rsv = 0 # Onl...
python
async def _send_frame(self, message: bytes, opcode: int, compress: Optional[int]=None) -> None: """Send a frame over the websocket with message as its payload.""" if self._closing: ws_logger.warning('websocket connection is closing.') rsv = 0 # Onl...
[ "async", "def", "_send_frame", "(", "self", ",", "message", ":", "bytes", ",", "opcode", ":", "int", ",", "compress", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "None", ":", "if", "self", ".", "_closing", ":", "ws_logger", ".", "warnin...
Send a frame over the websocket with message as its payload.
[ "Send", "a", "frame", "over", "the", "websocket", "with", "message", "as", "its", "payload", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_websocket.py#L561-L620
train
aio-libs/aiohttp
aiohttp/http_websocket.py
WebSocketWriter.pong
async def pong(self, message: bytes=b'') -> None: """Send pong message.""" if isinstance(message, str): message = message.encode('utf-8') await self._send_frame(message, WSMsgType.PONG)
python
async def pong(self, message: bytes=b'') -> None: """Send pong message.""" if isinstance(message, str): message = message.encode('utf-8') await self._send_frame(message, WSMsgType.PONG)
[ "async", "def", "pong", "(", "self", ",", "message", ":", "bytes", "=", "b''", ")", "->", "None", ":", "if", "isinstance", "(", "message", ",", "str", ")", ":", "message", "=", "message", ".", "encode", "(", "'utf-8'", ")", "await", "self", ".", "_...
Send pong message.
[ "Send", "pong", "message", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_websocket.py#L622-L626
train
aio-libs/aiohttp
aiohttp/http_websocket.py
WebSocketWriter.ping
async def ping(self, message: bytes=b'') -> None: """Send ping message.""" if isinstance(message, str): message = message.encode('utf-8') await self._send_frame(message, WSMsgType.PING)
python
async def ping(self, message: bytes=b'') -> None: """Send ping message.""" if isinstance(message, str): message = message.encode('utf-8') await self._send_frame(message, WSMsgType.PING)
[ "async", "def", "ping", "(", "self", ",", "message", ":", "bytes", "=", "b''", ")", "->", "None", ":", "if", "isinstance", "(", "message", ",", "str", ")", ":", "message", "=", "message", ".", "encode", "(", "'utf-8'", ")", "await", "self", ".", "_...
Send ping message.
[ "Send", "ping", "message", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_websocket.py#L628-L632
train
aio-libs/aiohttp
aiohttp/http_websocket.py
WebSocketWriter.send
async def send(self, message: Union[str, bytes], binary: bool=False, compress: Optional[int]=None) -> None: """Send a frame over the websocket with message as its payload.""" if isinstance(message, str): message = message.encode('utf-8') if binar...
python
async def send(self, message: Union[str, bytes], binary: bool=False, compress: Optional[int]=None) -> None: """Send a frame over the websocket with message as its payload.""" if isinstance(message, str): message = message.encode('utf-8') if binar...
[ "async", "def", "send", "(", "self", ",", "message", ":", "Union", "[", "str", ",", "bytes", "]", ",", "binary", ":", "bool", "=", "False", ",", "compress", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "None", ":", "if", "isinstance", ...
Send a frame over the websocket with message as its payload.
[ "Send", "a", "frame", "over", "the", "websocket", "with", "message", "as", "its", "payload", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_websocket.py#L634-L643
train
aio-libs/aiohttp
aiohttp/http_websocket.py
WebSocketWriter.close
async def close(self, code: int=1000, message: bytes=b'') -> None: """Close the websocket, sending the specified code and message.""" if isinstance(message, str): message = message.encode('utf-8') try: await self._send_frame( PACK_CLOSE_CODE(code) + messag...
python
async def close(self, code: int=1000, message: bytes=b'') -> None: """Close the websocket, sending the specified code and message.""" if isinstance(message, str): message = message.encode('utf-8') try: await self._send_frame( PACK_CLOSE_CODE(code) + messag...
[ "async", "def", "close", "(", "self", ",", "code", ":", "int", "=", "1000", ",", "message", ":", "bytes", "=", "b''", ")", "->", "None", ":", "if", "isinstance", "(", "message", ",", "str", ")", ":", "message", "=", "message", ".", "encode", "(", ...
Close the websocket, sending the specified code and message.
[ "Close", "the", "websocket", "sending", "the", "specified", "code", "and", "message", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_websocket.py#L645-L653
train
aio-libs/aiohttp
aiohttp/cookiejar.py
CookieJar.update_cookies
def update_cookies(self, cookies: LooseCookies, response_url: URL=URL()) -> None: """Update cookies.""" hostname = response_url.raw_host if not self._unsafe and is_ip_address(hostname): # Don't accept cookies from IPs return ...
python
def update_cookies(self, cookies: LooseCookies, response_url: URL=URL()) -> None: """Update cookies.""" hostname = response_url.raw_host if not self._unsafe and is_ip_address(hostname): # Don't accept cookies from IPs return ...
[ "def", "update_cookies", "(", "self", ",", "cookies", ":", "LooseCookies", ",", "response_url", ":", "URL", "=", "URL", "(", ")", ")", "->", "None", ":", "hostname", "=", "response_url", ".", "raw_host", "if", "not", "self", ".", "_unsafe", "and", "is_ip...
Update cookies.
[ "Update", "cookies", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/cookiejar.py#L113-L186
train
aio-libs/aiohttp
aiohttp/cookiejar.py
CookieJar.filter_cookies
def filter_cookies(self, request_url: URL=URL()) -> 'BaseCookie[str]': """Returns this jar's cookies filtered by their attributes.""" self._do_expiration() request_url = URL(request_url) filtered = SimpleCookie() hostname = request_url.raw_host or "" is_not_secure = reque...
python
def filter_cookies(self, request_url: URL=URL()) -> 'BaseCookie[str]': """Returns this jar's cookies filtered by their attributes.""" self._do_expiration() request_url = URL(request_url) filtered = SimpleCookie() hostname = request_url.raw_host or "" is_not_secure = reque...
[ "def", "filter_cookies", "(", "self", ",", "request_url", ":", "URL", "=", "URL", "(", ")", ")", "->", "'BaseCookie[str]'", ":", "self", ".", "_do_expiration", "(", ")", "request_url", "=", "URL", "(", "request_url", ")", "filtered", "=", "SimpleCookie", "...
Returns this jar's cookies filtered by their attributes.
[ "Returns", "this", "jar", "s", "cookies", "filtered", "by", "their", "attributes", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/cookiejar.py#L188-L226
train
aio-libs/aiohttp
aiohttp/cookiejar.py
CookieJar._is_domain_match
def _is_domain_match(domain: str, hostname: str) -> bool: """Implements domain matching adhering to RFC 6265.""" if hostname == domain: return True if not hostname.endswith(domain): return False non_matching = hostname[:-len(domain)] if not non_matching...
python
def _is_domain_match(domain: str, hostname: str) -> bool: """Implements domain matching adhering to RFC 6265.""" if hostname == domain: return True if not hostname.endswith(domain): return False non_matching = hostname[:-len(domain)] if not non_matching...
[ "def", "_is_domain_match", "(", "domain", ":", "str", ",", "hostname", ":", "str", ")", "->", "bool", ":", "if", "hostname", "==", "domain", ":", "return", "True", "if", "not", "hostname", ".", "endswith", "(", "domain", ")", ":", "return", "False", "n...
Implements domain matching adhering to RFC 6265.
[ "Implements", "domain", "matching", "adhering", "to", "RFC", "6265", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/cookiejar.py#L229-L242
train
aio-libs/aiohttp
aiohttp/cookiejar.py
CookieJar._is_path_match
def _is_path_match(req_path: str, cookie_path: str) -> bool: """Implements path matching adhering to RFC 6265.""" if not req_path.startswith("/"): req_path = "/" if req_path == cookie_path: return True if not req_path.startswith(cookie_path): return ...
python
def _is_path_match(req_path: str, cookie_path: str) -> bool: """Implements path matching adhering to RFC 6265.""" if not req_path.startswith("/"): req_path = "/" if req_path == cookie_path: return True if not req_path.startswith(cookie_path): return ...
[ "def", "_is_path_match", "(", "req_path", ":", "str", ",", "cookie_path", ":", "str", ")", "->", "bool", ":", "if", "not", "req_path", ".", "startswith", "(", "\"/\"", ")", ":", "req_path", "=", "\"/\"", "if", "req_path", "==", "cookie_path", ":", "retur...
Implements path matching adhering to RFC 6265.
[ "Implements", "path", "matching", "adhering", "to", "RFC", "6265", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/cookiejar.py#L245-L261
train
aio-libs/aiohttp
aiohttp/cookiejar.py
CookieJar._parse_date
def _parse_date(cls, date_str: str) -> Optional[datetime.datetime]: """Implements date string parsing adhering to RFC 6265.""" if not date_str: return None found_time = False found_day = False found_month = False found_year = False hour = minute = se...
python
def _parse_date(cls, date_str: str) -> Optional[datetime.datetime]: """Implements date string parsing adhering to RFC 6265.""" if not date_str: return None found_time = False found_day = False found_month = False found_year = False hour = minute = se...
[ "def", "_parse_date", "(", "cls", ",", "date_str", ":", "str", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "if", "not", "date_str", ":", "return", "None", "found_time", "=", "False", "found_day", "=", "False", "found_month", "=", "...
Implements date string parsing adhering to RFC 6265.
[ "Implements", "date", "string", "parsing", "adhering", "to", "RFC", "6265", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/cookiejar.py#L264-L327
train
aio-libs/aiohttp
examples/legacy/tcp_protocol_parser.py
my_protocol_parser
def my_protocol_parser(out, buf): """Parser is used with StreamParser for incremental protocol parsing. Parser is a generator function, but it is not a coroutine. Usually parsers are implemented as a state machine. more details in asyncio/parsers.py existing parsers: * HTTP protocol parsers a...
python
def my_protocol_parser(out, buf): """Parser is used with StreamParser for incremental protocol parsing. Parser is a generator function, but it is not a coroutine. Usually parsers are implemented as a state machine. more details in asyncio/parsers.py existing parsers: * HTTP protocol parsers a...
[ "def", "my_protocol_parser", "(", "out", ",", "buf", ")", ":", "while", "True", ":", "tp", "=", "yield", "from", "buf", ".", "read", "(", "5", ")", "if", "tp", "in", "(", "MSG_PING", ",", "MSG_PONG", ")", ":", "# skip line", "yield", "from", "buf", ...
Parser is used with StreamParser for incremental protocol parsing. Parser is a generator function, but it is not a coroutine. Usually parsers are implemented as a state machine. more details in asyncio/parsers.py existing parsers: * HTTP protocol parsers asyncio/http/protocol.py * websocket...
[ "Parser", "is", "used", "with", "StreamParser", "for", "incremental", "protocol", "parsing", ".", "Parser", "is", "a", "generator", "function", "but", "it", "is", "not", "a", "coroutine", ".", "Usually", "parsers", "are", "implemented", "as", "a", "state", "...
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/examples/legacy/tcp_protocol_parser.py#L23-L46
train
aio-libs/aiohttp
aiohttp/payload.py
Payload.set_content_disposition
def set_content_disposition(self, disptype: str, quote_fields: bool=True, **params: Any) -> None: """Sets ``Content-Disposition`` header.""" self._headers[hdrs.CONTENT_DISPOSITION] = content_disposition_heade...
python
def set_content_disposition(self, disptype: str, quote_fields: bool=True, **params: Any) -> None: """Sets ``Content-Disposition`` header.""" self._headers[hdrs.CONTENT_DISPOSITION] = content_disposition_heade...
[ "def", "set_content_disposition", "(", "self", ",", "disptype", ":", "str", ",", "quote_fields", ":", "bool", "=", "True", ",", "*", "*", "params", ":", "Any", ")", "->", "None", ":", "self", ".", "_headers", "[", "hdrs", ".", "CONTENT_DISPOSITION", "]",...
Sets ``Content-Disposition`` header.
[ "Sets", "Content", "-", "Disposition", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/payload.py#L187-L193
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.clone
def clone(self, *, method: str=sentinel, rel_url: StrOrURL=sentinel, headers: LooseHeaders=sentinel, scheme: str=sentinel, host: str=sentinel, remote: str=sentinel) -> 'BaseRequest': """Clone itself with replacement some attributes. Creates and returns a new in...
python
def clone(self, *, method: str=sentinel, rel_url: StrOrURL=sentinel, headers: LooseHeaders=sentinel, scheme: str=sentinel, host: str=sentinel, remote: str=sentinel) -> 'BaseRequest': """Clone itself with replacement some attributes. Creates and returns a new in...
[ "def", "clone", "(", "self", ",", "*", ",", "method", ":", "str", "=", "sentinel", ",", "rel_url", ":", "StrOrURL", "=", "sentinel", ",", "headers", ":", "LooseHeaders", "=", "sentinel", ",", "scheme", ":", "str", "=", "sentinel", ",", "host", ":", "...
Clone itself with replacement some attributes. Creates and returns a new instance of Request object. If no parameters are given, an exact copy is returned. If a parameter is not passed, it will reuse the one from the current request object.
[ "Clone", "itself", "with", "replacement", "some", "attributes", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L148-L196
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.forwarded
def forwarded(self) -> Tuple[Mapping[str, str], ...]: """A tuple containing all parsed Forwarded header(s). Makes an effort to parse Forwarded headers as specified by RFC 7239: - It adds one (immutable) dictionary per Forwarded 'field-value', ie per proxy. The element corresponds to ...
python
def forwarded(self) -> Tuple[Mapping[str, str], ...]: """A tuple containing all parsed Forwarded header(s). Makes an effort to parse Forwarded headers as specified by RFC 7239: - It adds one (immutable) dictionary per Forwarded 'field-value', ie per proxy. The element corresponds to ...
[ "def", "forwarded", "(", "self", ")", "->", "Tuple", "[", "Mapping", "[", "str", ",", "str", "]", ",", "...", "]", ":", "elems", "=", "[", "]", "for", "field_value", "in", "self", ".", "_message", ".", "headers", ".", "getall", "(", "hdrs", ".", ...
A tuple containing all parsed Forwarded header(s). Makes an effort to parse Forwarded headers as specified by RFC 7239: - It adds one (immutable) dictionary per Forwarded 'field-value', ie per proxy. The element corresponds to the data in the Forwarded field-value added by the firs...
[ "A", "tuple", "containing", "all", "parsed", "Forwarded", "header", "(", "s", ")", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L259-L318
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.host
def host(self) -> str: """Hostname of the request. Hostname is resolved in this order: - overridden value by .clone(host=new_host) call. - HOST HTTP header - socket.getfqdn() value """ host = self._message.headers.get(hdrs.HOST) if host is not None: ...
python
def host(self) -> str: """Hostname of the request. Hostname is resolved in this order: - overridden value by .clone(host=new_host) call. - HOST HTTP header - socket.getfqdn() value """ host = self._message.headers.get(hdrs.HOST) if host is not None: ...
[ "def", "host", "(", "self", ")", "->", "str", ":", "host", "=", "self", ".", "_message", ".", "headers", ".", "get", "(", "hdrs", ".", "HOST", ")", "if", "host", "is", "not", "None", ":", "return", "host", "else", ":", "return", "socket", ".", "g...
Hostname of the request. Hostname is resolved in this order: - overridden value by .clone(host=new_host) call. - HOST HTTP header - socket.getfqdn() value
[ "Hostname", "of", "the", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L353-L366
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.remote
def remote(self) -> Optional[str]: """Remote IP of client initiated HTTP request. The IP is resolved in this order: - overridden value by .clone(remote=new_remote) call. - peername of opened socket """ if isinstance(self._transport_peername, (list, tuple)): ...
python
def remote(self) -> Optional[str]: """Remote IP of client initiated HTTP request. The IP is resolved in this order: - overridden value by .clone(remote=new_remote) call. - peername of opened socket """ if isinstance(self._transport_peername, (list, tuple)): ...
[ "def", "remote", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "isinstance", "(", "self", ".", "_transport_peername", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "self", ".", "_transport_peername", "[", "0", "]", "else", ...
Remote IP of client initiated HTTP request. The IP is resolved in this order: - overridden value by .clone(remote=new_remote) call. - peername of opened socket
[ "Remote", "IP", "of", "client", "initiated", "HTTP", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L369-L380
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest._http_date
def _http_date(_date_str: str) -> Optional[datetime.datetime]: """Process a date string, return a datetime object """ if _date_str is not None: timetuple = parsedate(_date_str) if timetuple is not None: return datetime.datetime(*timetuple[:6], ...
python
def _http_date(_date_str: str) -> Optional[datetime.datetime]: """Process a date string, return a datetime object """ if _date_str is not None: timetuple = parsedate(_date_str) if timetuple is not None: return datetime.datetime(*timetuple[:6], ...
[ "def", "_http_date", "(", "_date_str", ":", "str", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "if", "_date_str", "is", "not", "None", ":", "timetuple", "=", "parsedate", "(", "_date_str", ")", "if", "timetuple", "is", "not", "None...
Process a date string, return a datetime object
[ "Process", "a", "date", "string", "return", "a", "datetime", "object" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L436-L444
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.if_modified_since
def if_modified_since(self) -> Optional[datetime.datetime]: """The value of If-Modified-Since HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_MODIFIED_SINCE))
python
def if_modified_since(self) -> Optional[datetime.datetime]: """The value of If-Modified-Since HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_MODIFIED_SINCE))
[ "def", "if_modified_since", "(", "self", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "return", "self", ".", "_http_date", "(", "self", ".", "headers", ".", "get", "(", "hdrs", ".", "IF_MODIFIED_SINCE", ")", ")" ]
The value of If-Modified-Since HTTP header, or None. This header is represented as a `datetime` object.
[ "The", "value", "of", "If", "-", "Modified", "-", "Since", "HTTP", "header", "or", "None", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L447-L452
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.if_unmodified_since
def if_unmodified_since(self) -> Optional[datetime.datetime]: """The value of If-Unmodified-Since HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_UNMODIFIED_SINCE))
python
def if_unmodified_since(self) -> Optional[datetime.datetime]: """The value of If-Unmodified-Since HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_UNMODIFIED_SINCE))
[ "def", "if_unmodified_since", "(", "self", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "return", "self", ".", "_http_date", "(", "self", ".", "headers", ".", "get", "(", "hdrs", ".", "IF_UNMODIFIED_SINCE", ")", ")" ]
The value of If-Unmodified-Since HTTP header, or None. This header is represented as a `datetime` object.
[ "The", "value", "of", "If", "-", "Unmodified", "-", "Since", "HTTP", "header", "or", "None", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L455-L460
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.if_range
def if_range(self) -> Optional[datetime.datetime]: """The value of If-Range HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_RANGE))
python
def if_range(self) -> Optional[datetime.datetime]: """The value of If-Range HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_RANGE))
[ "def", "if_range", "(", "self", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "return", "self", ".", "_http_date", "(", "self", ".", "headers", ".", "get", "(", "hdrs", ".", "IF_RANGE", ")", ")" ]
The value of If-Range HTTP header, or None. This header is represented as a `datetime` object.
[ "The", "value", "of", "If", "-", "Range", "HTTP", "header", "or", "None", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L463-L468
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.cookies
def cookies(self) -> Mapping[str, str]: """Return request cookies. A read-only dictionary-like object. """ raw = self.headers.get(hdrs.COOKIE, '') parsed = SimpleCookie(raw) return MappingProxyType( {key: val.value for key, val in parsed.items()})
python
def cookies(self) -> Mapping[str, str]: """Return request cookies. A read-only dictionary-like object. """ raw = self.headers.get(hdrs.COOKIE, '') parsed = SimpleCookie(raw) return MappingProxyType( {key: val.value for key, val in parsed.items()})
[ "def", "cookies", "(", "self", ")", "->", "Mapping", "[", "str", ",", "str", "]", ":", "raw", "=", "self", ".", "headers", ".", "get", "(", "hdrs", ".", "COOKIE", ",", "''", ")", "parsed", "=", "SimpleCookie", "(", "raw", ")", "return", "MappingPro...
Return request cookies. A read-only dictionary-like object.
[ "Return", "request", "cookies", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L476-L484
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.http_range
def http_range(self) -> slice: """The content of Range HTTP header. Return a slice instance. """ rng = self._headers.get(hdrs.RANGE) start, end = None, None if rng is not None: try: pattern = r'^bytes=(\d*)-(\d*)$' start, end ...
python
def http_range(self) -> slice: """The content of Range HTTP header. Return a slice instance. """ rng = self._headers.get(hdrs.RANGE) start, end = None, None if rng is not None: try: pattern = r'^bytes=(\d*)-(\d*)$' start, end ...
[ "def", "http_range", "(", "self", ")", "->", "slice", ":", "rng", "=", "self", ".", "_headers", ".", "get", "(", "hdrs", ".", "RANGE", ")", "start", ",", "end", "=", "None", ",", "None", "if", "rng", "is", "not", "None", ":", "try", ":", "pattern...
The content of Range HTTP header. Return a slice instance.
[ "The", "content", "of", "Range", "HTTP", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L487-L520
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.has_body
def has_body(self) -> bool: """Return True if request's HTTP BODY can be read, False otherwise.""" warnings.warn( "Deprecated, use .can_read_body #2005", DeprecationWarning, stacklevel=2) return not self._payload.at_eof()
python
def has_body(self) -> bool: """Return True if request's HTTP BODY can be read, False otherwise.""" warnings.warn( "Deprecated, use .can_read_body #2005", DeprecationWarning, stacklevel=2) return not self._payload.at_eof()
[ "def", "has_body", "(", "self", ")", "->", "bool", ":", "warnings", ".", "warn", "(", "\"Deprecated, use .can_read_body #2005\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ")", "return", "not", "self", ".", "_payload", ".", "at_eof", "(", ")" ]
Return True if request's HTTP BODY can be read, False otherwise.
[ "Return", "True", "if", "request", "s", "HTTP", "BODY", "can", "be", "read", "False", "otherwise", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L528-L533
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.read
async def read(self) -> bytes: """Read request body if present. Returns bytes object with full request content. """ if self._read_bytes is None: body = bytearray() while True: chunk = await self._payload.readany() body.extend(chunk...
python
async def read(self) -> bytes: """Read request body if present. Returns bytes object with full request content. """ if self._read_bytes is None: body = bytearray() while True: chunk = await self._payload.readany() body.extend(chunk...
[ "async", "def", "read", "(", "self", ")", "->", "bytes", ":", "if", "self", ".", "_read_bytes", "is", "None", ":", "body", "=", "bytearray", "(", ")", "while", "True", ":", "chunk", "=", "await", "self", ".", "_payload", ".", "readany", "(", ")", "...
Read request body if present. Returns bytes object with full request content.
[ "Read", "request", "body", "if", "present", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L553-L573
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.text
async def text(self) -> str: """Return BODY as text using encoding from .charset.""" bytes_body = await self.read() encoding = self.charset or 'utf-8' return bytes_body.decode(encoding)
python
async def text(self) -> str: """Return BODY as text using encoding from .charset.""" bytes_body = await self.read() encoding = self.charset or 'utf-8' return bytes_body.decode(encoding)
[ "async", "def", "text", "(", "self", ")", "->", "str", ":", "bytes_body", "=", "await", "self", ".", "read", "(", ")", "encoding", "=", "self", ".", "charset", "or", "'utf-8'", "return", "bytes_body", ".", "decode", "(", "encoding", ")" ]
Return BODY as text using encoding from .charset.
[ "Return", "BODY", "as", "text", "using", "encoding", "from", ".", "charset", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L575-L579
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.json
async def json(self, *, loads: JSONDecoder=DEFAULT_JSON_DECODER) -> Any: """Return BODY as JSON.""" body = await self.text() return loads(body)
python
async def json(self, *, loads: JSONDecoder=DEFAULT_JSON_DECODER) -> Any: """Return BODY as JSON.""" body = await self.text() return loads(body)
[ "async", "def", "json", "(", "self", ",", "*", ",", "loads", ":", "JSONDecoder", "=", "DEFAULT_JSON_DECODER", ")", "->", "Any", ":", "body", "=", "await", "self", ".", "text", "(", ")", "return", "loads", "(", "body", ")" ]
Return BODY as JSON.
[ "Return", "BODY", "as", "JSON", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L581-L584
train
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.post
async def post(self) -> 'MultiDictProxy[Union[str, bytes, FileField]]': """Return POST parameters.""" if self._post is not None: return self._post if self._method not in self.POST_METHODS: self._post = MultiDictProxy(MultiDict()) return self._post con...
python
async def post(self) -> 'MultiDictProxy[Union[str, bytes, FileField]]': """Return POST parameters.""" if self._post is not None: return self._post if self._method not in self.POST_METHODS: self._post = MultiDictProxy(MultiDict()) return self._post con...
[ "async", "def", "post", "(", "self", ")", "->", "'MultiDictProxy[Union[str, bytes, FileField]]'", ":", "if", "self", ".", "_post", "is", "not", "None", ":", "return", "self", ".", "_post", "if", "self", ".", "_method", "not", "in", "self", ".", "POST_METHODS...
Return POST parameters.
[ "Return", "POST", "parameters", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L590-L662
train
aio-libs/aiohttp
aiohttp/web_protocol.py
RequestHandler.shutdown
async def shutdown(self, timeout: Optional[float]=15.0) -> None: """Worker process is about to exit, we need cleanup everything and stop accepting requests. It is especially important for keep-alive connections.""" self._force_close = True if self._keepalive_handle is not None: ...
python
async def shutdown(self, timeout: Optional[float]=15.0) -> None: """Worker process is about to exit, we need cleanup everything and stop accepting requests. It is especially important for keep-alive connections.""" self._force_close = True if self._keepalive_handle is not None: ...
[ "async", "def", "shutdown", "(", "self", ",", "timeout", ":", "Optional", "[", "float", "]", "=", "15.0", ")", "->", "None", ":", "self", ".", "_force_close", "=", "True", "if", "self", ".", "_keepalive_handle", "is", "not", "None", ":", "self", ".", ...
Worker process is about to exit, we need cleanup everything and stop accepting requests. It is especially important for keep-alive connections.
[ "Worker", "process", "is", "about", "to", "exit", "we", "need", "cleanup", "everything", "and", "stop", "accepting", "requests", ".", "It", "is", "especially", "important", "for", "keep", "-", "alive", "connections", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_protocol.py#L184-L213
train
aio-libs/aiohttp
aiohttp/web_protocol.py
RequestHandler.keep_alive
def keep_alive(self, val: bool) -> None: """Set keep-alive connection mode. :param bool val: new state. """ self._keepalive = val if self._keepalive_handle: self._keepalive_handle.cancel() self._keepalive_handle = None
python
def keep_alive(self, val: bool) -> None: """Set keep-alive connection mode. :param bool val: new state. """ self._keepalive = val if self._keepalive_handle: self._keepalive_handle.cancel() self._keepalive_handle = None
[ "def", "keep_alive", "(", "self", ",", "val", ":", "bool", ")", "->", "None", ":", "self", ".", "_keepalive", "=", "val", "if", "self", ".", "_keepalive_handle", ":", "self", ".", "_keepalive_handle", ".", "cancel", "(", ")", "self", ".", "_keepalive_han...
Set keep-alive connection mode. :param bool val: new state.
[ "Set", "keep", "-", "alive", "connection", "mode", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_protocol.py#L316-L324
train
aio-libs/aiohttp
aiohttp/web_protocol.py
RequestHandler.close
def close(self) -> None: """Stop accepting new pipelinig messages and close connection when handlers done processing messages""" self._close = True if self._waiter: self._waiter.cancel()
python
def close(self) -> None: """Stop accepting new pipelinig messages and close connection when handlers done processing messages""" self._close = True if self._waiter: self._waiter.cancel()
[ "def", "close", "(", "self", ")", "->", "None", ":", "self", ".", "_close", "=", "True", "if", "self", ".", "_waiter", ":", "self", ".", "_waiter", ".", "cancel", "(", ")" ]
Stop accepting new pipelinig messages and close connection when handlers done processing messages
[ "Stop", "accepting", "new", "pipelinig", "messages", "and", "close", "connection", "when", "handlers", "done", "processing", "messages" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_protocol.py#L326-L331
train
aio-libs/aiohttp
aiohttp/web_protocol.py
RequestHandler.force_close
def force_close(self) -> None: """Force close connection""" self._force_close = True if self._waiter: self._waiter.cancel() if self.transport is not None: self.transport.close() self.transport = None
python
def force_close(self) -> None: """Force close connection""" self._force_close = True if self._waiter: self._waiter.cancel() if self.transport is not None: self.transport.close() self.transport = None
[ "def", "force_close", "(", "self", ")", "->", "None", ":", "self", ".", "_force_close", "=", "True", "if", "self", ".", "_waiter", ":", "self", ".", "_waiter", ".", "cancel", "(", ")", "if", "self", ".", "transport", "is", "not", "None", ":", "self",...
Force close connection
[ "Force", "close", "connection" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_protocol.py#L333-L340
train
aio-libs/aiohttp
aiohttp/web_protocol.py
RequestHandler.start
async def start(self) -> None: """Process incoming request. It reads request line, request headers and request payload, then calls handle_request() method. Subclass has to override handle_request(). start() handles various exceptions in request or response handling. Connection i...
python
async def start(self) -> None: """Process incoming request. It reads request line, request headers and request payload, then calls handle_request() method. Subclass has to override handle_request(). start() handles various exceptions in request or response handling. Connection i...
[ "async", "def", "start", "(", "self", ")", "->", "None", ":", "loop", "=", "self", ".", "_loop", "handler", "=", "self", ".", "_task_handler", "assert", "handler", "is", "not", "None", "manager", "=", "self", ".", "_manager", "assert", "manager", "is", ...
Process incoming request. It reads request line, request headers and request payload, then calls handle_request() method. Subclass has to override handle_request(). start() handles various exceptions in request or response handling. Connection is being closed always unless keep_...
[ "Process", "incoming", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_protocol.py#L373-L509
train
aio-libs/aiohttp
aiohttp/web_protocol.py
RequestHandler.handle_error
def handle_error(self, request: BaseRequest, status: int=500, exc: Optional[BaseException]=None, message: Optional[str]=None) -> StreamResponse: """Handle errors. Returns HTTP response with specific status code. Logs ad...
python
def handle_error(self, request: BaseRequest, status: int=500, exc: Optional[BaseException]=None, message: Optional[str]=None) -> StreamResponse: """Handle errors. Returns HTTP response with specific status code. Logs ad...
[ "def", "handle_error", "(", "self", ",", "request", ":", "BaseRequest", ",", "status", ":", "int", "=", "500", ",", "exc", ":", "Optional", "[", "BaseException", "]", "=", "None", ",", "message", ":", "Optional", "[", "str", "]", "=", "None", ")", "-...
Handle errors. Returns HTTP response with specific status code. Logs additional information. It always closes current connection.
[ "Handle", "errors", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_protocol.py#L511-L556
train
aio-libs/aiohttp
aiohttp/web.py
run_app
def run_app(app: Union[Application, Awaitable[Application]], *, host: Optional[str]=None, port: Optional[int]=None, path: Optional[str]=None, sock: Optional[socket.socket]=None, shutdown_timeout: float=60.0, ssl_context: Optional[SSLContext]=None, ...
python
def run_app(app: Union[Application, Awaitable[Application]], *, host: Optional[str]=None, port: Optional[int]=None, path: Optional[str]=None, sock: Optional[socket.socket]=None, shutdown_timeout: float=60.0, ssl_context: Optional[SSLContext]=None, ...
[ "def", "run_app", "(", "app", ":", "Union", "[", "Application", ",", "Awaitable", "[", "Application", "]", "]", ",", "*", ",", "host", ":", "Optional", "[", "str", "]", "=", "None", ",", "port", ":", "Optional", "[", "int", "]", "=", "None", ",", ...
Run an app locally
[ "Run", "an", "app", "locally" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web.py#L375-L422
train
aio-libs/aiohttp
aiohttp/streams.py
AsyncStreamReaderMixin.iter_chunked
def iter_chunked(self, n: int) -> AsyncStreamIterator[bytes]: """Returns an asynchronous iterator that yields chunks of size n. Python-3.5 available for Python 3.5+ only """ return AsyncStreamIterator(lambda: self.read(n))
python
def iter_chunked(self, n: int) -> AsyncStreamIterator[bytes]: """Returns an asynchronous iterator that yields chunks of size n. Python-3.5 available for Python 3.5+ only """ return AsyncStreamIterator(lambda: self.read(n))
[ "def", "iter_chunked", "(", "self", ",", "n", ":", "int", ")", "->", "AsyncStreamIterator", "[", "bytes", "]", ":", "return", "AsyncStreamIterator", "(", "lambda", ":", "self", ".", "read", "(", "n", ")", ")" ]
Returns an asynchronous iterator that yields chunks of size n. Python-3.5 available for Python 3.5+ only
[ "Returns", "an", "asynchronous", "iterator", "that", "yields", "chunks", "of", "size", "n", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/streams.py#L68-L73
train
aio-libs/aiohttp
aiohttp/streams.py
StreamReader.unread_data
def unread_data(self, data: bytes) -> None: """ rollback reading some data from stream, inserting it to buffer head. """ warnings.warn("unread_data() is deprecated " "and will be removed in future releases (#3260)", DeprecationWarning, ...
python
def unread_data(self, data: bytes) -> None: """ rollback reading some data from stream, inserting it to buffer head. """ warnings.warn("unread_data() is deprecated " "and will be removed in future releases (#3260)", DeprecationWarning, ...
[ "def", "unread_data", "(", "self", ",", "data", ":", "bytes", ")", "->", "None", ":", "warnings", ".", "warn", "(", "\"unread_data() is deprecated \"", "\"and will be removed in future releases (#3260)\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ")", ...
rollback reading some data from stream, inserting it to buffer head.
[ "rollback", "reading", "some", "data", "from", "stream", "inserting", "it", "to", "buffer", "head", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/streams.py#L211-L227
train
aio-libs/aiohttp
aiohttp/streams.py
StreamReader.readchunk
async def readchunk(self) -> Tuple[bytes, bool]: """Returns a tuple of (data, end_of_http_chunk). When chunked transfer encoding is used, end_of_http_chunk is a boolean indicating if the end of the data corresponds to the end of a HTTP chunk , otherwise it is always False. """ ...
python
async def readchunk(self) -> Tuple[bytes, bool]: """Returns a tuple of (data, end_of_http_chunk). When chunked transfer encoding is used, end_of_http_chunk is a boolean indicating if the end of the data corresponds to the end of a HTTP chunk , otherwise it is always False. """ ...
[ "async", "def", "readchunk", "(", "self", ")", "->", "Tuple", "[", "bytes", ",", "bool", "]", ":", "while", "True", ":", "if", "self", ".", "_exception", "is", "not", "None", ":", "raise", "self", ".", "_exception", "while", "self", ".", "_http_chunk_s...
Returns a tuple of (data, end_of_http_chunk). When chunked transfer encoding is used, end_of_http_chunk is a boolean indicating if the end of the data corresponds to the end of a HTTP chunk , otherwise it is always False.
[ "Returns", "a", "tuple", "of", "(", "data", "end_of_http_chunk", ")", ".", "When", "chunked", "transfer", "encoding", "is", "used", "end_of_http_chunk", "is", "a", "boolean", "indicating", "if", "the", "end", "of", "the", "data", "corresponds", "to", "the", ...
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/streams.py#L385-L413
train
aio-libs/aiohttp
aiohttp/streams.py
StreamReader._read_nowait
def _read_nowait(self, n: int) -> bytes: """ Read not more than n bytes, or whole buffer is n == -1 """ chunks = [] while self._buffer: chunk = self._read_nowait_chunk(n) chunks.append(chunk) if n != -1: n -= len(chunk) if n ==...
python
def _read_nowait(self, n: int) -> bytes: """ Read not more than n bytes, or whole buffer is n == -1 """ chunks = [] while self._buffer: chunk = self._read_nowait_chunk(n) chunks.append(chunk) if n != -1: n -= len(chunk) if n ==...
[ "def", "_read_nowait", "(", "self", ",", "n", ":", "int", ")", "->", "bytes", ":", "chunks", "=", "[", "]", "while", "self", ".", "_buffer", ":", "chunk", "=", "self", ".", "_read_nowait_chunk", "(", "n", ")", "chunks", ".", "append", "(", "chunk", ...
Read not more than n bytes, or whole buffer is n == -1
[ "Read", "not", "more", "than", "n", "bytes", "or", "whole", "buffer", "is", "n", "==", "-", "1" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/streams.py#L472-L484
train
aio-libs/aiohttp
aiohttp/signals.py
Signal.send
async def send(self, *args, **kwargs): """ Sends data to all registered receivers. """ if not self.frozen: raise RuntimeError("Cannot send non-frozen signal.") for receiver in self: await receiver(*args, **kwargs)
python
async def send(self, *args, **kwargs): """ Sends data to all registered receivers. """ if not self.frozen: raise RuntimeError("Cannot send non-frozen signal.") for receiver in self: await receiver(*args, **kwargs)
[ "async", "def", "send", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "frozen", ":", "raise", "RuntimeError", "(", "\"Cannot send non-frozen signal.\"", ")", "for", "receiver", "in", "self", ":", "await", "re...
Sends data to all registered receivers.
[ "Sends", "data", "to", "all", "registered", "receivers", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/signals.py#L26-L34
train
aio-libs/aiohttp
aiohttp/web_log.py
AccessLogger.compile_format
def compile_format(self, log_format: str) -> Tuple[str, List[KeyMethod]]: """Translate log_format into form usable by modulo formatting All known atoms will be replaced with %s Also methods for formatting of those atoms will be added to _methods in appropriate order For example...
python
def compile_format(self, log_format: str) -> Tuple[str, List[KeyMethod]]: """Translate log_format into form usable by modulo formatting All known atoms will be replaced with %s Also methods for formatting of those atoms will be added to _methods in appropriate order For example...
[ "def", "compile_format", "(", "self", ",", "log_format", ":", "str", ")", "->", "Tuple", "[", "str", ",", "List", "[", "KeyMethod", "]", "]", ":", "# list of (key, method) tuples, we don't use an OrderedDict as users", "# can repeat the same key more than once", "methods"...
Translate log_format into form usable by modulo formatting All known atoms will be replaced with %s Also methods for formatting of those atoms will be added to _methods in appropriate order For example we have log_format = "%a %t" This format will be translated to "%s %s" ...
[ "Translate", "log_format", "into", "form", "usable", "by", "modulo", "formatting" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_log.py#L78-L118
train
aio-libs/aiohttp
aiohttp/web_middlewares.py
normalize_path_middleware
def normalize_path_middleware( *, append_slash: bool=True, remove_slash: bool=False, merge_slashes: bool=True, redirect_class: Type[HTTPMove]=HTTPMovedPermanently) -> _Middleware: """ Middleware factory which produces a middleware that normalizes the path of a request. By normalizing...
python
def normalize_path_middleware( *, append_slash: bool=True, remove_slash: bool=False, merge_slashes: bool=True, redirect_class: Type[HTTPMove]=HTTPMovedPermanently) -> _Middleware: """ Middleware factory which produces a middleware that normalizes the path of a request. By normalizing...
[ "def", "normalize_path_middleware", "(", "*", ",", "append_slash", ":", "bool", "=", "True", ",", "remove_slash", ":", "bool", "=", "False", ",", "merge_slashes", ":", "bool", "=", "True", ",", "redirect_class", ":", "Type", "[", "HTTPMove", "]", "=", "HTT...
Middleware factory which produces a middleware that normalizes the path of a request. By normalizing it means: - Add or remove a trailing slash to the path. - Double slashes are replaced by one. The middleware returns as soon as it finds a path that resolves correctly. The order if both me...
[ "Middleware", "factory", "which", "produces", "a", "middleware", "that", "normalizes", "the", "path", "of", "a", "request", ".", "By", "normalizing", "it", "means", ":" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_middlewares.py#L42-L111
train
aio-libs/aiohttp
aiohttp/formdata.py
FormData._gen_form_data
def _gen_form_data(self) -> multipart.MultipartWriter: """Encode a list of fields using the multipart/form-data MIME format""" for dispparams, headers, value in self._fields: try: if hdrs.CONTENT_TYPE in headers: part = payload.get_payload( ...
python
def _gen_form_data(self) -> multipart.MultipartWriter: """Encode a list of fields using the multipart/form-data MIME format""" for dispparams, headers, value in self._fields: try: if hdrs.CONTENT_TYPE in headers: part = payload.get_payload( ...
[ "def", "_gen_form_data", "(", "self", ")", "->", "multipart", ".", "MultipartWriter", ":", "for", "dispparams", ",", "headers", ",", "value", "in", "self", ".", "_fields", ":", "try", ":", "if", "hdrs", ".", "CONTENT_TYPE", "in", "headers", ":", "part", ...
Encode a list of fields using the multipart/form-data MIME format
[ "Encode", "a", "list", "of", "fields", "using", "the", "multipart", "/", "form", "-", "data", "MIME", "format" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/formdata.py#L116-L144
train
aio-libs/aiohttp
aiohttp/http_writer.py
StreamWriter.write
async def write(self, chunk: bytes, *, drain: bool=True, LIMIT: int=0x10000) -> None: """Writes chunk of data to a stream. write_eof() indicates end of stream. writer can't be used after write_eof() method being called. write() return drain future. """ ...
python
async def write(self, chunk: bytes, *, drain: bool=True, LIMIT: int=0x10000) -> None: """Writes chunk of data to a stream. write_eof() indicates end of stream. writer can't be used after write_eof() method being called. write() return drain future. """ ...
[ "async", "def", "write", "(", "self", ",", "chunk", ":", "bytes", ",", "*", ",", "drain", ":", "bool", "=", "True", ",", "LIMIT", ":", "int", "=", "0x10000", ")", "->", "None", ":", "if", "self", ".", "_on_chunk_sent", "is", "not", "None", ":", "...
Writes chunk of data to a stream. write_eof() indicates end of stream. writer can't be used after write_eof() method being called. write() return drain future.
[ "Writes", "chunk", "of", "data", "to", "a", "stream", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_writer.py#L70-L105
train
aio-libs/aiohttp
aiohttp/http_writer.py
StreamWriter.write_headers
async def write_headers(self, status_line: str, headers: 'CIMultiDict[str]') -> None: """Write request/response status and headers.""" # status + headers buf = _serialize_headers(status_line, headers) self._write(buf)
python
async def write_headers(self, status_line: str, headers: 'CIMultiDict[str]') -> None: """Write request/response status and headers.""" # status + headers buf = _serialize_headers(status_line, headers) self._write(buf)
[ "async", "def", "write_headers", "(", "self", ",", "status_line", ":", "str", ",", "headers", ":", "'CIMultiDict[str]'", ")", "->", "None", ":", "# status + headers", "buf", "=", "_serialize_headers", "(", "status_line", ",", "headers", ")", "self", ".", "_wri...
Write request/response status and headers.
[ "Write", "request", "/", "response", "status", "and", "headers", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_writer.py#L107-L112
train
aio-libs/aiohttp
aiohttp/helpers.py
netrc_from_env
def netrc_from_env() -> Optional[netrc.netrc]: """Attempt to load the netrc file from the path specified by the env-var NETRC or in the default location in the user's home directory. Returns None if it couldn't be found or fails to parse. """ netrc_env = os.environ.get('NETRC') if netrc_env is...
python
def netrc_from_env() -> Optional[netrc.netrc]: """Attempt to load the netrc file from the path specified by the env-var NETRC or in the default location in the user's home directory. Returns None if it couldn't be found or fails to parse. """ netrc_env = os.environ.get('NETRC') if netrc_env is...
[ "def", "netrc_from_env", "(", ")", "->", "Optional", "[", "netrc", ".", "netrc", "]", ":", "netrc_env", "=", "os", ".", "environ", ".", "get", "(", "'NETRC'", ")", "if", "netrc_env", "is", "not", "None", ":", "netrc_path", "=", "Path", "(", "netrc_env"...
Attempt to load the netrc file from the path specified by the env-var NETRC or in the default location in the user's home directory. Returns None if it couldn't be found or fails to parse.
[ "Attempt", "to", "load", "the", "netrc", "file", "from", "the", "path", "specified", "by", "the", "env", "-", "var", "NETRC", "or", "in", "the", "default", "location", "in", "the", "user", "s", "home", "directory", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L186-L219
train
aio-libs/aiohttp
aiohttp/helpers.py
parse_mimetype
def parse_mimetype(mimetype: str) -> MimeType: """Parses a MIME type into its components. mimetype is a MIME type string. Returns a MimeType object. Example: >>> parse_mimetype('text/html; charset=utf-8') MimeType(type='text', subtype='html', suffix='', parameters={'charset': 'u...
python
def parse_mimetype(mimetype: str) -> MimeType: """Parses a MIME type into its components. mimetype is a MIME type string. Returns a MimeType object. Example: >>> parse_mimetype('text/html; charset=utf-8') MimeType(type='text', subtype='html', suffix='', parameters={'charset': 'u...
[ "def", "parse_mimetype", "(", "mimetype", ":", "str", ")", "->", "MimeType", ":", "if", "not", "mimetype", ":", "return", "MimeType", "(", "type", "=", "''", ",", "subtype", "=", "''", ",", "suffix", "=", "''", ",", "parameters", "=", "MultiDictProxy", ...
Parses a MIME type into its components. mimetype is a MIME type string. Returns a MimeType object. Example: >>> parse_mimetype('text/html; charset=utf-8') MimeType(type='text', subtype='html', suffix='', parameters={'charset': 'utf-8'})
[ "Parses", "a", "MIME", "type", "into", "its", "components", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L291-L328
train
aio-libs/aiohttp
aiohttp/helpers.py
content_disposition_header
def content_disposition_header(disptype: str, quote_fields: bool=True, **params: str) -> str: """Sets ``Content-Disposition`` header. disptype is a disposition type: inline, attachment, form-data. Should be valid extension token (see RFC 2183) ...
python
def content_disposition_header(disptype: str, quote_fields: bool=True, **params: str) -> str: """Sets ``Content-Disposition`` header. disptype is a disposition type: inline, attachment, form-data. Should be valid extension token (see RFC 2183) ...
[ "def", "content_disposition_header", "(", "disptype", ":", "str", ",", "quote_fields", ":", "bool", "=", "True", ",", "*", "*", "params", ":", "str", ")", "->", "str", ":", "if", "not", "disptype", "or", "not", "(", "TOKEN", ">", "set", "(", "disptype"...
Sets ``Content-Disposition`` header. disptype is a disposition type: inline, attachment, form-data. Should be valid extension token (see RFC 2183) params is a dict with disposition params.
[ "Sets", "Content", "-", "Disposition", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L338-L365
train
aio-libs/aiohttp
aiohttp/helpers.py
BasicAuth.decode
def decode(cls, auth_header: str, encoding: str='latin1') -> 'BasicAuth': """Create a BasicAuth object from an Authorization HTTP header.""" try: auth_type, encoded_credentials = auth_header.split(' ', 1) except ValueError: raise ValueError('Could not parse authorization ...
python
def decode(cls, auth_header: str, encoding: str='latin1') -> 'BasicAuth': """Create a BasicAuth object from an Authorization HTTP header.""" try: auth_type, encoded_credentials = auth_header.split(' ', 1) except ValueError: raise ValueError('Could not parse authorization ...
[ "def", "decode", "(", "cls", ",", "auth_header", ":", "str", ",", "encoding", ":", "str", "=", "'latin1'", ")", "->", "'BasicAuth'", ":", "try", ":", "auth_type", ",", "encoded_credentials", "=", "auth_header", ".", "split", "(", "' '", ",", "1", ")", ...
Create a BasicAuth object from an Authorization HTTP header.
[ "Create", "a", "BasicAuth", "object", "from", "an", "Authorization", "HTTP", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L134-L160
train
aio-libs/aiohttp
aiohttp/helpers.py
BasicAuth.from_url
def from_url(cls, url: URL, *, encoding: str='latin1') -> Optional['BasicAuth']: """Create BasicAuth from url.""" if not isinstance(url, URL): raise TypeError("url should be yarl.URL instance") if url.user is None: return None return cls(url.user,...
python
def from_url(cls, url: URL, *, encoding: str='latin1') -> Optional['BasicAuth']: """Create BasicAuth from url.""" if not isinstance(url, URL): raise TypeError("url should be yarl.URL instance") if url.user is None: return None return cls(url.user,...
[ "def", "from_url", "(", "cls", ",", "url", ":", "URL", ",", "*", ",", "encoding", ":", "str", "=", "'latin1'", ")", "->", "Optional", "[", "'BasicAuth'", "]", ":", "if", "not", "isinstance", "(", "url", ",", "URL", ")", ":", "raise", "TypeError", "...
Create BasicAuth from url.
[ "Create", "BasicAuth", "from", "url", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L163-L170
train
aio-libs/aiohttp
aiohttp/helpers.py
BasicAuth.encode
def encode(self) -> str: """Encode credentials.""" creds = ('%s:%s' % (self.login, self.password)).encode(self.encoding) return 'Basic %s' % base64.b64encode(creds).decode(self.encoding)
python
def encode(self) -> str: """Encode credentials.""" creds = ('%s:%s' % (self.login, self.password)).encode(self.encoding) return 'Basic %s' % base64.b64encode(creds).decode(self.encoding)
[ "def", "encode", "(", "self", ")", "->", "str", ":", "creds", "=", "(", "'%s:%s'", "%", "(", "self", ".", "login", ",", "self", ".", "password", ")", ")", ".", "encode", "(", "self", ".", "encoding", ")", "return", "'Basic %s'", "%", "base64", ".",...
Encode credentials.
[ "Encode", "credentials", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L172-L175
train
aio-libs/aiohttp
aiohttp/helpers.py
HeadersMixin.content_type
def content_type(self) -> str: """The value of content part for Content-Type HTTP header.""" raw = self._headers.get(hdrs.CONTENT_TYPE) # type: ignore if self._stored_content_type != raw: self._parse_content_type(raw) return self._content_type
python
def content_type(self) -> str: """The value of content part for Content-Type HTTP header.""" raw = self._headers.get(hdrs.CONTENT_TYPE) # type: ignore if self._stored_content_type != raw: self._parse_content_type(raw) return self._content_type
[ "def", "content_type", "(", "self", ")", "->", "str", ":", "raw", "=", "self", ".", "_headers", ".", "get", "(", "hdrs", ".", "CONTENT_TYPE", ")", "# type: ignore", "if", "self", ".", "_stored_content_type", "!=", "raw", ":", "self", ".", "_parse_content_t...
The value of content part for Content-Type HTTP header.
[ "The", "value", "of", "content", "part", "for", "Content", "-", "Type", "HTTP", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L624-L629
train
aio-libs/aiohttp
aiohttp/helpers.py
HeadersMixin.charset
def charset(self) -> Optional[str]: """The value of charset part for Content-Type HTTP header.""" raw = self._headers.get(hdrs.CONTENT_TYPE) # type: ignore if self._stored_content_type != raw: self._parse_content_type(raw) return self._content_dict.get('charset')
python
def charset(self) -> Optional[str]: """The value of charset part for Content-Type HTTP header.""" raw = self._headers.get(hdrs.CONTENT_TYPE) # type: ignore if self._stored_content_type != raw: self._parse_content_type(raw) return self._content_dict.get('charset')
[ "def", "charset", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "raw", "=", "self", ".", "_headers", ".", "get", "(", "hdrs", ".", "CONTENT_TYPE", ")", "# type: ignore", "if", "self", ".", "_stored_content_type", "!=", "raw", ":", "self", "...
The value of charset part for Content-Type HTTP header.
[ "The", "value", "of", "charset", "part", "for", "Content", "-", "Type", "HTTP", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L632-L637
train
aio-libs/aiohttp
aiohttp/helpers.py
HeadersMixin.content_length
def content_length(self) -> Optional[int]: """The value of Content-Length HTTP header.""" content_length = self._headers.get(hdrs.CONTENT_LENGTH) # type: ignore if content_length is not None: return int(content_length) else: return None
python
def content_length(self) -> Optional[int]: """The value of Content-Length HTTP header.""" content_length = self._headers.get(hdrs.CONTENT_LENGTH) # type: ignore if content_length is not None: return int(content_length) else: return None
[ "def", "content_length", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "content_length", "=", "self", ".", "_headers", ".", "get", "(", "hdrs", ".", "CONTENT_LENGTH", ")", "# type: ignore", "if", "content_length", "is", "not", "None", ":", "ret...
The value of Content-Length HTTP header.
[ "The", "value", "of", "Content", "-", "Length", "HTTP", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L640-L647
train
aio-libs/aiohttp
aiohttp/client.py
request
def request( method: str, url: StrOrURL, *, params: Optional[Mapping[str, str]]=None, data: Any=None, json: Any=None, headers: LooseHeaders=None, skip_auto_headers: Optional[Iterable[str]]=None, auth: Optional[BasicAuth]=None, allow_redirects: bool...
python
def request( method: str, url: StrOrURL, *, params: Optional[Mapping[str, str]]=None, data: Any=None, json: Any=None, headers: LooseHeaders=None, skip_auto_headers: Optional[Iterable[str]]=None, auth: Optional[BasicAuth]=None, allow_redirects: bool...
[ "def", "request", "(", "method", ":", "str", ",", "url", ":", "StrOrURL", ",", "*", ",", "params", ":", "Optional", "[", "Mapping", "[", "str", ",", "str", "]", "]", "=", "None", ",", "data", ":", "Any", "=", "None", ",", "json", ":", "Any", "=...
Constructs and sends a request. Returns response object. method - HTTP method url - request url params - (optional) Dictionary or bytes to be sent in the query string of the new request data - (optional) Dictionary, bytes, or file-like object to send in the body of the request json - (op...
[ "Constructs", "and", "sends", "a", "request", ".", "Returns", "response", "object", ".", "method", "-", "HTTP", "method", "url", "-", "request", "url", "params", "-", "(", "optional", ")", "Dictionary", "or", "bytes", "to", "be", "sent", "in", "the", "qu...
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L1035-L1119
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession.request
def request(self, method: str, url: StrOrURL, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP request.""" return _RequestContextManager(self._request(method, url, **kwargs))
python
def request(self, method: str, url: StrOrURL, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP request.""" return _RequestContextManager(self._request(method, url, **kwargs))
[ "def", "request", "(", "self", ",", "method", ":", "str", ",", "url", ":", "StrOrURL", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_request", "(", "method", ",", ...
Perform HTTP request.
[ "Perform", "HTTP", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L297-L302
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession.ws_connect
def ws_connect( self, url: StrOrURL, *, method: str=hdrs.METH_GET, protocols: Iterable[str]=(), timeout: float=10.0, receive_timeout: Optional[float]=None, autoclose: bool=True, autoping: bool=True, heartbeat: Op...
python
def ws_connect( self, url: StrOrURL, *, method: str=hdrs.METH_GET, protocols: Iterable[str]=(), timeout: float=10.0, receive_timeout: Optional[float]=None, autoclose: bool=True, autoping: bool=True, heartbeat: Op...
[ "def", "ws_connect", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "method", ":", "str", "=", "hdrs", ".", "METH_GET", ",", "protocols", ":", "Iterable", "[", "str", "]", "=", "(", ")", ",", "timeout", ":", "float", "=", "10.0", ",", "...
Initiate websocket connection.
[ "Initiate", "websocket", "connection", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L604-L641
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession._prepare_headers
def _prepare_headers( self, headers: Optional[LooseHeaders]) -> 'CIMultiDict[str]': """ Add default headers and transform it to CIMultiDict """ # Convert headers to MultiDict result = CIMultiDict(self._default_headers) if headers: if not isinst...
python
def _prepare_headers( self, headers: Optional[LooseHeaders]) -> 'CIMultiDict[str]': """ Add default headers and transform it to CIMultiDict """ # Convert headers to MultiDict result = CIMultiDict(self._default_headers) if headers: if not isinst...
[ "def", "_prepare_headers", "(", "self", ",", "headers", ":", "Optional", "[", "LooseHeaders", "]", ")", "->", "'CIMultiDict[str]'", ":", "# Convert headers to MultiDict", "result", "=", "CIMultiDict", "(", "self", ".", "_default_headers", ")", "if", "headers", ":"...
Add default headers and transform it to CIMultiDict
[ "Add", "default", "headers", "and", "transform", "it", "to", "CIMultiDict" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L800-L817
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession.get
def get(self, url: StrOrURL, *, allow_redirects: bool=True, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP GET request.""" return _RequestContextManager( self._request(hdrs.METH_GET, url, allow_redirects=allow_redirects, ...
python
def get(self, url: StrOrURL, *, allow_redirects: bool=True, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP GET request.""" return _RequestContextManager( self._request(hdrs.METH_GET, url, allow_redirects=allow_redirects, ...
[ "def", "get", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "allow_redirects", ":", "bool", "=", "True", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_r...
Perform HTTP GET request.
[ "Perform", "HTTP", "GET", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L819-L825
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession.options
def options(self, url: StrOrURL, *, allow_redirects: bool=True, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP OPTIONS request.""" return _RequestContextManager( self._request(hdrs.METH_OPTIONS, url, allow_redirects=allow_redirects, ...
python
def options(self, url: StrOrURL, *, allow_redirects: bool=True, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP OPTIONS request.""" return _RequestContextManager( self._request(hdrs.METH_OPTIONS, url, allow_redirects=allow_redirects, ...
[ "def", "options", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "allow_redirects", ":", "bool", "=", "True", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", ...
Perform HTTP OPTIONS request.
[ "Perform", "HTTP", "OPTIONS", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L827-L833
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession.head
def head(self, url: StrOrURL, *, allow_redirects: bool=False, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP HEAD request.""" return _RequestContextManager( self._request(hdrs.METH_HEAD, url, allow_redirects=allow_redirects, ...
python
def head(self, url: StrOrURL, *, allow_redirects: bool=False, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP HEAD request.""" return _RequestContextManager( self._request(hdrs.METH_HEAD, url, allow_redirects=allow_redirects, ...
[ "def", "head", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "allow_redirects", ":", "bool", "=", "False", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "...
Perform HTTP HEAD request.
[ "Perform", "HTTP", "HEAD", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L835-L841
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession.post
def post(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP POST request.""" return _RequestContextManager( self._request(hdrs.METH_POST, url, data=data, **kwargs))
python
def post(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP POST request.""" return _RequestContextManager( self._request(hdrs.METH_POST, url, data=data, **kwargs))
[ "def", "post", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "data", ":", "Any", "=", "None", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_request", ...
Perform HTTP POST request.
[ "Perform", "HTTP", "POST", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L843-L849
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession.put
def put(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP PUT request.""" return _RequestContextManager( self._request(hdrs.METH_PUT, url, data=data, **kwargs))
python
def put(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP PUT request.""" return _RequestContextManager( self._request(hdrs.METH_PUT, url, data=data, **kwargs))
[ "def", "put", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "data", ":", "Any", "=", "None", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_request", "...
Perform HTTP PUT request.
[ "Perform", "HTTP", "PUT", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L851-L857
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession.patch
def patch(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP PATCH request.""" return _RequestContextManager( self._request(hdrs.METH_PATCH, url, data=data, **kwargs))
python
def patch(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP PATCH request.""" return _RequestContextManager( self._request(hdrs.METH_PATCH, url, data=data, **kwargs))
[ "def", "patch", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "data", ":", "Any", "=", "None", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_request", ...
Perform HTTP PATCH request.
[ "Perform", "HTTP", "PATCH", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L859-L865
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession.delete
def delete(self, url: StrOrURL, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP DELETE request.""" return _RequestContextManager( self._request(hdrs.METH_DELETE, url, **kwargs))
python
def delete(self, url: StrOrURL, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP DELETE request.""" return _RequestContextManager( self._request(hdrs.METH_DELETE, url, **kwargs))
[ "def", "delete", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_request", "(", "hdrs", ".", "METH_DELETE", ",", "url", ",", ...
Perform HTTP DELETE request.
[ "Perform", "HTTP", "DELETE", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L867-L871
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession.close
async def close(self) -> None: """Close underlying connector. Release all acquired resources. """ if not self.closed: if self._connector is not None and self._connector_owner: await self._connector.close() self._connector = None
python
async def close(self) -> None: """Close underlying connector. Release all acquired resources. """ if not self.closed: if self._connector is not None and self._connector_owner: await self._connector.close() self._connector = None
[ "async", "def", "close", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "closed", ":", "if", "self", ".", "_connector", "is", "not", "None", "and", "self", ".", "_connector_owner", ":", "await", "self", ".", "_connector", ".", "close", ...
Close underlying connector. Release all acquired resources.
[ "Close", "underlying", "connector", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L873-L881
train
aio-libs/aiohttp
aiohttp/client.py
ClientSession.requote_redirect_url
def requote_redirect_url(self, val: bool) -> None: """Do URL requoting on redirection handling.""" warnings.warn("session.requote_redirect_url modification " "is deprecated #2778", DeprecationWarning, stacklevel=2) self._requote_r...
python
def requote_redirect_url(self, val: bool) -> None: """Do URL requoting on redirection handling.""" warnings.warn("session.requote_redirect_url modification " "is deprecated #2778", DeprecationWarning, stacklevel=2) self._requote_r...
[ "def", "requote_redirect_url", "(", "self", ",", "val", ":", "bool", ")", "->", "None", ":", "warnings", ".", "warn", "(", "\"session.requote_redirect_url modification \"", "\"is deprecated #2778\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ")", "self...
Do URL requoting on redirection handling.
[ "Do", "URL", "requoting", "on", "redirection", "handling", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L912-L918
train
aio-libs/aiohttp
aiohttp/abc.py
AbstractResolver.resolve
async def resolve(self, host: str, port: int, family: int) -> List[Dict[str, Any]]: """Return IP address for given hostname"""
python
async def resolve(self, host: str, port: int, family: int) -> List[Dict[str, Any]]: """Return IP address for given hostname"""
[ "async", "def", "resolve", "(", "self", ",", "host", ":", "str", ",", "port", ":", "int", ",", "family", ":", "int", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":" ]
Return IP address for given hostname
[ "Return", "IP", "address", "for", "given", "hostname" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/abc.py#L126-L128
train