golden hour
/opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/tornado/__pycache__
⬆️ Go Up
Upload
File/Folder
Size
Actions
__init__.cpython-310.pyc
378 B
Del
OK
_locale_data.cpython-310.pyc
3.23 KB
Del
OK
auth.cpython-310.pyc
39.18 KB
Del
OK
autoreload.cpython-310.pyc
7.02 KB
Del
OK
concurrent.cpython-310.pyc
17.24 KB
Del
OK
curl_httpclient.cpython-310.pyc
12.8 KB
Del
OK
escape.cpython-310.pyc
9.89 KB
Del
OK
gen.cpython-310.pyc
38.39 KB
Del
OK
http1connection.cpython-310.pyc
19.47 KB
Del
OK
httpclient.cpython-310.pyc
25.19 KB
Del
OK
httpserver.cpython-310.pyc
11.45 KB
Del
OK
httputil.cpython-310.pyc
29.84 KB
Del
OK
ioloop.cpython-310.pyc
33.19 KB
Del
OK
iostream.cpython-310.pyc
42.97 KB
Del
OK
locale.cpython-310.pyc
15.22 KB
Del
OK
locks.cpython-310.pyc
16.61 KB
Del
OK
log.cpython-310.pyc
8.07 KB
Del
OK
netutil.cpython-310.pyc
14.32 KB
Del
OK
options.cpython-310.pyc
19.63 KB
Del
OK
process.cpython-310.pyc
10.27 KB
Del
OK
queues.cpython-310.pyc
11.29 KB
Del
OK
routing.cpython-310.pyc
21.08 KB
Del
OK
simple_httpclient.cpython-310.pyc
16.08 KB
Del
OK
stack_context.cpython-310.pyc
10.65 KB
Del
OK
tcpclient.cpython-310.pyc
6.49 KB
Del
OK
tcpserver.cpython-310.pyc
10.06 KB
Del
OK
template.cpython-310.pyc
30.52 KB
Del
OK
testing.cpython-310.pyc
24.61 KB
Del
OK
util.cpython-310.pyc
13.72 KB
Del
OK
web.cpython-310.pyc
105.22 KB
Del
OK
websocket.cpython-310.pyc
39.08 KB
Del
OK
wsgi.cpython-310.pyc
11.5 KB
Del
OK
Edit: websocket.cpython-310.pyc
o �xeǻ � @ s� d Z ddlmZmZmZ ddlZddlZddlZddlZddl Z ddl m m m Z ddlm m mZ ddlZddlmZ ddl mZmZmZ ddlmZmZmZ ddlmZmZ ddlm Z dd l!m"Z"m#Z# dd lm$Z$ ddl%m&Z& ddl'm(Z(m)Z) e)r�dd l*m+Z+ e,Z-ndd l+m+Z+ G dd� de.�Z/G dd� de/�Z0G dd� dej1�Z2dd� Z3G dd� de4�Z5G dd� de4�Z6G dd� de4�Z7G dd� de5�Z8G dd� de$j9�Z: d"d d!�Z;dS )#a� Implementation of the WebSocket protocol. `WebSockets <http://dev.w3.org/html5/websockets/>`_ allow for bidirectional communication between the browser and server. WebSockets are supported in the current versions of all major browsers, although older versions that do not support WebSockets are still in use (refer to http://caniuse.com/websockets for details). This module implements the final version of the WebSocket protocol as defined in `RFC 6455 <http://tools.ietf.org/html/rfc6455>`_. Certain browser versions (notably Safari 5.x) implemented an earlier draft of the protocol (known as "draft 76") and are not compatible with this module. .. versionchanged:: 4.0 Removed support for the draft 76 protocol version. � )�absolute_import�division�print_functionN)�TracebackFuture)�utf8� native_str� to_unicode)�gen� httpclient�httputil)�IOLoop�PeriodicCallback)�StreamClosedError)�gen_log�app_log)�simple_httpclient)� TCPClient)�_websocket_mask�PY3)�urlparsec @ s e Zd ZdS )�WebSocketErrorN)�__name__� __module__�__qualname__� r r �N/opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/tornado/websocket.pyr 1 s r c @ s e Zd ZdZdS )�WebSocketClosedErrorzLRaised by operations on a closed connection. .. versionadded:: 3.2 N)r r r �__doc__r r r r r 5 s r c s� e Zd ZdZ� fdd�Zejdd� �ZdZe dd� �Z e d d � �Ze dd� �Zd0dd�Z dd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zd1d d!�Zd"d#� Zd$d%� Zd&d'� Z� fd(d)�Z� fd*d+�Zd,d-� Zd.d/� Z� ZS )2�WebSocketHandlera� Subclass this class to create a basic WebSocket handler. Override `on_message` to handle incoming messages, and use `write_message` to send messages to the client. You can also override `open` and `on_close` to handle opened and closed connections. Custom upgrade response headers can be sent by overriding `~tornado.web.RequestHandler.set_default_headers` or `~tornado.web.RequestHandler.prepare`. See http://dev.w3.org/html5/websockets/ for details on the JavaScript interface. The protocol is specified at http://tools.ietf.org/html/rfc6455. Here is an example WebSocket handler that echos back all received messages back to the client: .. testcode:: class EchoWebSocket(tornado.websocket.WebSocketHandler): def open(self): print("WebSocket opened") def on_message(self, message): self.write_message(u"You said: " + message) def on_close(self): print("WebSocket closed") .. testoutput:: :hide: WebSockets are not standard HTTP connections. The "handshake" is HTTP, but after the handshake, the protocol is message-based. Consequently, most of the Tornado HTTP facilities are not available in handlers of this type. The only communication methods available to you are `write_message()`, `ping()`, and `close()`. Likewise, your request handler class should implement `open()` method rather than ``get()`` or ``post()``. If you map the handler above to ``/websocket`` in your application, you can invoke it in JavaScript with:: var ws = new WebSocket("ws://localhost:8888/websocket"); ws.onopen = function() { ws.send("Hello, world"); }; ws.onmessage = function (evt) { alert(evt.data); }; This script pops up an alert box that says "You said: Hello, world". Web browsers allow any site to open a websocket connection to any other, instead of using the same-origin policy that governs other network access from javascript. This can be surprising and is a potential security hole, so since Tornado 4.0 `WebSocketHandler` requires applications that wish to receive cross-origin websockets to opt in by overriding the `~WebSocketHandler.check_origin` method (see that method's docs for details). Failure to do so is the most likely cause of 403 errors when making a websocket connection. When using a secure websocket connection (``wss://``) with a self-signed certificate, the connection from a browser may fail because it wants to show the "accept this certificate" dialog but has nowhere to show it. You must first visit a regular HTML page using the same certificate to accept it before the websocket connection will succeed. If the application setting ``websocket_ping_interval`` has a non-zero value, a ping will be sent periodically, and the connection will be closed if a response is not received before the ``websocket_ping_timeout``. Messages larger than the ``websocket_max_message_size`` application setting (default 10MiB) will not be accepted. .. versionchanged:: 4.5 Added ``websocket_ping_interval``, ``websocket_ping_timeout``, and ``websocket_max_message_size``. c s<