
    vKg                       S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKJ	r	J
r
JrJr  S SKJr  S SKJrJrJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJrJrJr  SSKJ r J!r!J"r"  SSK#J$r$J%r%J&r&  SSK'J(r(  SSKJ)r)J*r*J+r+J,r,  SSK-J.r.  SSK/J0r0J1r1  / SQr2 " S S\05      r3 " S S5      r4 " S S5      r5 S       SS jjr6SS jr7   S        S!S jjr8g)"    )annotationsN)	Awaitable	GeneratorIterableSequence)TracebackType)AnyCallablecast   )InvalidHeader)ServerExtensionFactory) enable_server_permessage_deflate)	CloseCode)build_www_authenticate_basicparse_authorization_basicvalidate_subprotocols)SERVERRequestResponse)
CONNECTINGOPENEvent)ServerProtocol)
LoggerLikeOrigin
StatusLikeSubprotocol   )asyncio_timeout)
Connection	broadcast)r"   serve
unix_serveServerConnectionServer
basic_authc                     ^  \ rS rSrSrSSSSSS.               SU 4S jjjrSS	 jrS
S
\4       SS jjrSU 4S jjr	SU 4S jjr
SrU =r$ )r%   (   a  
:mod:`asyncio` implementation of a WebSocket server connection.

:class:`ServerConnection` provides :meth:`recv` and :meth:`send` methods for
receiving and sending messages.

It supports asynchronous iteration to receive messages::

    async for message in websocket:
        await process(message)

The iterator exits normally when the connection is closed with close code
1000 (OK) or 1001 (going away) or without a close code. It raises a
:exc:`~websockets.exceptions.ConnectionClosedError` when the connection is
closed with any other code.

The ``ping_interval``, ``ping_timeout``, ``close_timeout``, ``max_queue``,
and ``write_limit`` arguments have the same meaning as in :func:`serve`.

Args:
    protocol: Sans-I/O connection.
    server: Server that manages this connection.

   
         ping_intervalping_timeoutclose_timeout	max_queuewrite_limitc          	     |   > U   [         TU ]  UUUUUUS9  X l        U R                  R	                  5       U l        U   g )Nr.   )super__init__serverloopcreate_futurerequest_rcvd)	selfprotocolr7   r/   r0   r1   r2   r3   	__class__s	           Y/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/websockets/asyncio/server.pyr6   ServerConnection.__init__B   sK     	'%'# 	 	
 26))2I2I2K    c                8    U R                   R                  X5      $ )a  
Create a plain text HTTP response.

``process_request`` and ``process_response`` may call this method to
return an HTTP response instead of performing the WebSocket opening
handshake.

You can modify the response before returning it, for example by changing
HTTP headers.

Args:
    status: HTTP status code.
    text: HTTP response body; it will be encoded to UTF-8.

Returns:
    HTTP response to send to the client.

)r<   reject)r;   statustexts      r>   respondServerConnection.respondZ   s    & }}##F11r@   Nc                  #    [         R                  " U R                  U R                  /[         R                  S9I Sh  vN   U R
                  Gb  U R                  [        S9 ISh  vN   SnUb2   U" X R
                  5      n[        U[        5      (       a
  UI Sh  vN nUc  U R"                  R%                  5       (       a+  U R                  R'                  U R
                  5      U l        OWU R                  R                  [        R                  R*                  S5      U l        O[        U[,        5      (       d   eX@l        U(       a  X0R(                  R.                  S'   SnUb=   U" X R
                  U R(                  5      n[        U[        5      (       a
  UI Sh  vN nUb  [        U[,        5      (       d   eX@l        U R                  R1                  U R(                  5        SSS5      ISh  vN   U R                  R                  b  U R                  R                  eg GN GN GN! [         aO  nXPR                  l        U R                  R                  [        R                  R                   S5      n SnAGNSnAff = f N! [         aO  nXPR                  l        U R                  R                  [        R                  R                   S5      n SnAGN>SnAff = f N! , ISh  vN  (       d  f       GN= f7f)z!
Perform the opening handshake.

)return_whenN)expected_statezLFailed to open a WebSocket connection.
See server log for more information.
zServer is shutting down.
r&   )asynciowaitr:   connection_lost_waiterFIRST_COMPLETEDrequestsend_contextr   
isinstancer   	Exceptionr<   handshake_excrB   http
HTTPStatusINTERNAL_SERVER_ERRORr7   
is_servingacceptresponseSERVICE_UNAVAILABLEr   headerssend_response)r;   process_requestprocess_responseserver_headerrX   excs         r>   	handshakeServerConnection.handshakeo   s^    , ll ; ;<//
 	
 	

 <<#((
(CC".#24#F%h	::-5~H #{{--//(,(<(<T\\(J(,(<(< OO??8)
 &h9999$,M 6CMM))(3#/#3D,,#V%h	::-5~H '%h9999$,M++DMM:m DC@ ==&&2----- 3M	
 D (6$ 693#'==#7#7 OOAA!I$> (6$ 693#'==#7#7 OOAA!I$Q DCCCs   =LH- )L)H0*L-K24,H6 H3!H6%CK2.7J%J&J*AK2/L:K0;3L0L3H66
J AJ
K2
JK2J
K-AK("K2(K--K20L2L
8K;9L
Lc                   > U R                   c9  [        U[        5      (       d   eXl         U R                  R	                  S5        g[
        TU ]  U5        g)z
Process one incoming event.

N)rN   rP   r   r:   
set_resultr5   process_event)r;   eventr=   s     r>   rd   ServerConnection.process_event   sJ     <<eW---- L((. G!%(r@   c                Z   > [         TU ]  U5        U R                  R                  U 5        g N)r5   connection_mader7   start_connection_handler)r;   	transportr=   s     r>   ri    ServerConnection.connection_made   s"    	*,,T2r@   )rN   r:   rX   r7   )r<   r   r7   r&   r/   float | Noner0   rm   r1   rm   r2   *int | None | tuple[int | None, int | None]r3   int | tuple[int, int | None]returnNone)rC   r   rD   strrp   r   )r\   ZCallable[[ServerConnection, Request], Awaitable[Response | None] | Response | None] | Noner]   dCallable[[ServerConnection, Request, Response], Awaitable[Response | None] | Response | None] | Noner^   
str | Nonerp   rq   )re   r   rp   rq   )rk   zasyncio.BaseTransportrp   rq   )__name__
__module____qualname____firstlineno____doc__r6   rE   r   r`   rd   ri   __static_attributes____classcell__)r=   s   @r>   r%   r%   (   s    < ')%'&(@B49  
 $ # $ > 2 
 02:  $*!].].].  "!]." 
#].~)3 3r@   r%   c                      \ rS rSrSrSS\SSS.             SS jjr\SS j5       rSS jr	SS	 jr
SS
 jrSSS jjrSS jrSS jrSS jrSS jrSS jrSS jr\SS j5       rS S jr        S!S jrSrg)"r&      a  
WebSocket server returned by :func:`serve`.

This class mirrors the API of :class:`asyncio.Server`.

It keeps track of WebSocket connections in order to close them properly
when shutting down.

Args:
    handler: Connection handler. It receives the WebSocket connection,
        which is a :class:`ServerConnection`, in argument.
    process_request: Intercept the request during the opening handshake.
        Return an HTTP response to force the response. Return :obj:`None` to
        continue normally. When you force an HTTP 101 Continue response, the
        handshake is successful. Else, the connection is aborted.
        ``process_request`` may be a function or a coroutine.
    process_response: Intercept the response during the opening handshake.
        Modify the response or return a new HTTP response to force the
        response. Return :obj:`None` to continue normally. When you force an
        HTTP 101 Continue response, the handshake is successful. Else, the
        connection is aborted. ``process_response`` may be a function or a
        coroutine.
    server_header: Value of  the ``Server`` response header.
        It defaults to ``"Python/x.y.z websockets/X.Y"``. Setting it to
        :obj:`None` removes the header.
    open_timeout: Timeout for opening connections in seconds.
        :obj:`None` disables the timeout.
    logger: Logger for this server.
        It defaults to ``logging.getLogger("websockets.server")``.
        See the :doc:`logging guide <../../topics/logging>` for details.

Nr+   r\   r]   r^   open_timeoutloggerc                  [         R                  " 5       U l        Xl        X l        X0l        X@l        XPl        Uc  [        R                  " S5      nX`l
        0 U l        S U l        U R                  R                  5       U l        g )Nzwebsockets.server)rJ   get_running_loopr8   handlerr\   r]   r^   r   logging	getLoggerr   handlers
close_taskr9   closed_waiter)r;   r   r\   r]   r^   r   r   s          r>   r6   Server.__init__  sw    , ,,.	. 0*(>&&':;F EG 6: 48993J3J3Lr@   c                l    U R                    Vs1 sH  oR                  [        L d  M  UiM     sn$ s  snf )z
Set of active connections.

This property contains all connections that completed the opening
handshake successfully and didn't start the closing handshake yet.
It can be useful in combination with :func:`~broadcast`.

)r   stater   r;   
connections     r>   connectionsServer.connections,  s,     .2]]W]z>N>NRV>V
]WWWs   11c                   Xl         UR                   H  nUR                  [        R                  :X  a  SUR                  5       -  nO}UR                  [        R                  :X  a  SUR                  5       SS -  nOHUR                  [        R                  :X  a  UR                  5       nO[        UR                  5       5      nU R                  R                  SU5        M     g)a  
Attach to a given :class:`asyncio.Server`.

Since :meth:`~asyncio.loop.create_server` doesn't support injecting a
custom ``Server`` class, the easiest solution that doesn't rely on
private :mod:`asyncio` APIs is to:

- instantiate a :class:`Server`
- give the protocol factory a reference to that instance
- call :meth:`~asyncio.loop.create_server` with the factory
- attach the resulting :class:`asyncio.Server` with this method

z%s:%dz[%s]:%dNr   zserver listening on %s)r7   socketsfamilysocketAF_INETgetsocknameAF_INET6AF_UNIXrr   r   info)r;   r7   socknames       r>   wrapServer.wrap8  s     NND{{fnn,!1!1!33/ 4#3#3#5bq#99.'') 4++-.KK5t< #r@   c                n  #     [        U R                  5       ISh  vN    UR                  U R                  U R                  U R
                  5      I Sh  vN   SSS5      ISh  vN   UR                  R                  [        La  UR                  5          U R                  U	 g UR!                  5         U R#                  U5      I Sh  vN   UR%                  5       I Sh  vN   U R                  U	 g N N! [        R                   a    UR                  5         e [         aK    UR                  R                  SSS9  UR                  5          SSS5      ISh  vN    U R                  U	 gf = f GN! , ISh  vN  (       d  f       GN'= f N N! [         aE    UR                  R                  SSS9  UR%                  [&        R(                  5      I Sh  vN     Nf = f! [*         a     GN[         a    UR,                  R/                  5          GN5f = f! U R                  U	 f = f7f)z
Handle the lifecycle of a WebSocket connection.

Since this method doesn't have a caller that can handle exceptions,
it attempts to log relevant ones.

It guarantees that the TCP connection is closed before exiting.

Nzopening handshake failedT)exc_infozconnection handler failed)r    r   r`   r\   r]   r^   rJ   CancelledErrorclose_transportrQ   r   errorr   r<   r   r   start_keepaliver   closer   INTERNAL_ERRORTimeoutErrorrk   abortr   s     r>   conn_handlerServer.conn_handlerT  s    *	*&t'8'899$..,,--**   :9 ""((4**,. j)+)**,ll:...
 !&&((( j)S :
 -- ..0  %%++,FQU+V..0 :99R j)? :999, /
 )	  A!!''(Cd'S &&y'?'?@@@A  	 	)  &&(	) j)s.  H5G, C8G, E;4C<C:C<G, 'E8(1G, H5)$F FF G, %F&G, *H58G, :C<<AE5E;G,  E#!G, &H54E55E;8G, ;FFFG, F G, AG) G#!G)&G, 'H# (G))G, ,
H 6H# 9#H H# H  H# #H22H5c                r    U R                   R                  U R                  U5      5      U R                  U'   g)z*
Register a connection with this server.

N)r8   create_taskr   r   r   s     r>   rj   Server.start_connection_handler  s,     %)II$9$9$:K:KJ:W$Xj!r@   c                    U R                   c4  U R                  5       R                  U R                  U5      5      U l         gg)a  
Close the server.

* Close the underlying :class:`asyncio.Server`.
* When ``close_connections`` is :obj:`True`, which is the default,
  close existing connections. Specifically:

  * Reject opening WebSocket connections with an HTTP 503 (service
    unavailable) error. This happens when the server accepted the TCP
    connection but didn't complete the opening handshake before closing.
  * Close open WebSocket connections with close code 1001 (going away).

* Wait until all connection handlers terminate.

:meth:`close` is idempotent.

N)r   get_loopr   _close)r;   close_connectionss     r>   r   Server.close  s8    $ ??""mmo99-.DO #r@   c                  #    U R                   R                  S5        U R                  R                  5         [        R
                  " S5      I Sh  vN   U(       a  U R                   Vs/ sHG  nUR                  R                  [        Ld  M"  [        R                  " UR                  S5      5      PMI     nnU(       a  [        R                  " U5      I Sh  vN   U R                  R                  5       I Sh  vN   U R                  (       a6  [        R                  " U R                  R                  5       5      I Sh  vN   U R                  R                  S5        U R                   R                  S5        g GN.s  snf  N N NG7f)z
Implementation of :meth:`close`.

This calls :meth:`~asyncio.Server.close` on the underlying
:class:`asyncio.Server` object to stop accepting new connections and
then closes open connections with close code 1001.

zserver closingr   Ni  zserver closed)r   r   r7   r   rJ   sleepr   r<   r   r   r   rK   wait_closedvaluesr   rc   )r;   r   r   close_taskss       r>   r   Server._close  s-     	)* 	
 mmA
 #'--"/J&&,,J> <##J$4$4T$:;"/   ll;/// kk%%''' ==,,t}}335666 	%%d+)3 	
 0 	(
 7s[   AFE?F+ F)F8"FF!F<F	=AFF<FF	FFc                `   #    [         R                  " U R                  5      I Sh  vN   g N7f)a"  
Wait until the server is closed.

When :meth:`wait_closed` returns, all TCP connections are closed and
all connection handlers have returned.

To ensure a fast shutdown, a connection handler should always be
awaiting at least one of:

* :meth:`~ServerConnection.recv`: when the connection is closed,
  it raises :exc:`~websockets.exceptions.ConnectionClosedOK`;
* :meth:`~ServerConnection.wait_closed`: when the connection is
  closed, it returns.

Then the connection handler is immediately notified of the shutdown;
it can clean up and exit.

N)rJ   shieldr   r;   s    r>   r   Server.wait_closed  s     & nnT//000   $.,.c                6    U R                   R                  5       $ )z'
See :meth:`asyncio.Server.get_loop`.

)r7   r   r   s    r>   r   Server.get_loop  s    
 {{##%%r@   c                6    U R                   R                  5       $ )z)
See :meth:`asyncio.Server.is_serving`.

)r7   rV   r   s    r>   rV   Server.is_serving  s    
 {{%%''r@   c                T   #    U R                   R                  5       I Sh  vN   g N7f)z
See :meth:`asyncio.Server.start_serving`.

Typical use::

    server = await serve(..., start_serving=False)
    # perform additional setup here...
    # ... then start the server
    await server.start_serving()

N)r7   start_servingr   s    r>   r   Server.start_serving  s      kk'')))   (&(c                T   #    U R                   R                  5       I Sh  vN   g N7f)a{  
See :meth:`asyncio.Server.serve_forever`.

Typical use::

    server = await serve(...)
    # this coroutine doesn't return
    # canceling it stops the server
    await server.serve_forever()

This is an alternative to using :func:`serve` as an asynchronous context
manager. Shutdown is triggered by canceling :meth:`serve_forever`
instead of exiting a :func:`serve` context.

N)r7   serve_foreverr   s    r>   r   Server.serve_forever	  s       kk'')))r   c                .    U R                   R                  $ )z&
See :attr:`asyncio.Server.sockets`.

)r7   r   r   s    r>   r   Server.sockets  s     {{"""r@   c                   #    U $ 7frh    r   s    r>   
__aenter__Server.__aenter__#  s
     s   c                `   #    U R                  5         U R                  5       I S h  vN   g  N7frh   )r   r   r;   exc_type	exc_value	tracebacks       r>   	__aexit__Server.__aexit__&  s"      	

   r   )r   r   r   r   r   r8   r   r\   r]   r7   r^   )r   -Callable[[ServerConnection], Awaitable[None]]r\   rs   r]   rt   r^   ru   r   rm   r   LoggerLike | Nonerp   rq   )rp   zset[ServerConnection])r7   zasyncio.Serverrp   rq   )r   r%   rp   rq   )T)r   boolrp   rq   )rp   rq   )rp   zasyncio.AbstractEventLoop)rp   r   )rp   zIterable[socket.socket]rp   r&   r   ztype[BaseException] | Noner   zBaseException | Noner   zTracebackType | Nonerp   rq   )rv   rw   rx   ry   rz   r   r6   propertyr   r   r   rj   r   r   r   r   rV   r   r   r   r   r   r{   r   r@   r>   r&   r&      s    V  $*%'$()'M>'M
'M'M$ "%'M& #''M( ")'M* 
+'MR 	X 	X=84*l	Y.**X1*&(**$ # #!,! (! (	!
 
!r@   r&   c                      \ rS rSrSr  SSSSSSS\SSSSSSSS	SSS
.                                           SS jjjrSS jr        SS jrSS jr	SS jr
\	rSrg)r#   i1  uo  
Create a WebSocket server listening on ``host`` and ``port``.

Whenever a client connects, the server creates a :class:`ServerConnection`,
performs the opening handshake, and delegates to the ``handler`` coroutine.

The handler receives the :class:`ServerConnection` instance, which you can
use to send and receive messages.

Once the handler completes, either normally or with an exception, the server
performs the closing handshake and closes the connection.

This coroutine returns a :class:`Server` whose API mirrors
:class:`asyncio.Server`. Treat it as an asynchronous context manager to
ensure that the server will be closed::

    from websockets.asyncio.server import serve

    def handler(websocket):
        ...

    # set this future to exit the server
    stop = asyncio.get_running_loop().create_future()

    async with serve(handler, host, port):
        await stop

Alternatively, call :meth:`~Server.serve_forever` to serve requests and
cancel it to stop the server::

    server = await serve(handler, host, port)
    await server.serve_forever()

Args:
    handler: Connection handler. It receives the WebSocket connection,
        which is a :class:`ServerConnection`, in argument.
    host: Network interfaces the server binds to.
        See :meth:`~asyncio.loop.create_server` for details.
    port: TCP port the server listens on.
        See :meth:`~asyncio.loop.create_server` for details.
    origins: Acceptable values of the ``Origin`` header, for defending
        against Cross-Site WebSocket Hijacking attacks. Include :obj:`None`
        in the list if the lack of an origin is acceptable.
    extensions: List of supported extensions, in order in which they
        should be negotiated and run.
    subprotocols: List of supported subprotocols, in order of decreasing
        preference.
    select_subprotocol: Callback for selecting a subprotocol among
        those supported by the client and the server. It receives a
        :class:`ServerConnection` (not a
        :class:`~websockets.server.ServerProtocol`!) instance and a list of
        subprotocols offered by the client. Other than the first argument,
        it has the same behavior as the
        :meth:`ServerProtocol.select_subprotocol
        <websockets.server.ServerProtocol.select_subprotocol>` method.
    process_request: Intercept the request during the opening handshake.
        Return an HTTP response to force the response or :obj:`None` to
        continue normally. When you force an HTTP 101 Continue response, the
        handshake is successful. Else, the connection is aborted.
        ``process_request`` may be a function or a coroutine.
    process_response: Intercept the response during the opening handshake.
        Return an HTTP response to force the response or :obj:`None` to
        continue normally. When you force an HTTP 101 Continue response, the
        handshake is successful. Else, the connection is aborted.
        ``process_response`` may be a function or a coroutine.
    server_header: Value of  the ``Server`` response header.
        It defaults to ``"Python/x.y.z websockets/X.Y"``. Setting it to
        :obj:`None` removes the header.
    compression: The "permessage-deflate" extension is enabled by default.
        Set ``compression`` to :obj:`None` to disable it. See the
        :doc:`compression guide <../../topics/compression>` for details.
    open_timeout: Timeout for opening connections in seconds.
        :obj:`None` disables the timeout.
    ping_interval: Interval between keepalive pings in seconds.
        :obj:`None` disables keepalive.
    ping_timeout: Timeout for keepalive pings in seconds.
        :obj:`None` disables timeouts.
    close_timeout: Timeout for closing connections in seconds.
        :obj:`None` disables the timeout.
    max_size: Maximum size of incoming messages in bytes.
        :obj:`None` disables the limit.
    max_queue: High-water mark of the buffer where frames are received.
        It defaults to 16 frames. The low-water mark defaults to ``max_queue
        // 4``. You may pass a ``(high, low)`` tuple to set the high-water
        and low-water marks. If you want to disable flow control entirely,
        you may set it to ``None``, although that's a bad idea.
    write_limit: High-water mark of write buffer in bytes. It is passed to
        :meth:`~asyncio.WriteTransport.set_write_buffer_limits`. It defaults
        to 32 KiB. You may pass a ``(high, low)`` tuple to set the
        high-water and low-water marks.
    logger: Logger for this server.
        It defaults to ``logging.getLogger("websockets.server")``. See the
        :doc:`logging guide <../../topics/logging>` for details.
    create_connection: Factory for the :class:`ServerConnection` managing
        the connection. Set it to a wrapper or a subclass to customize
        connection handling.

Any other keyword arguments are passed to the event loop's
:meth:`~asyncio.loop.create_server` method.

For example:

* You can set ``ssl`` to a :class:`~ssl.SSLContext` to enable TLS.

* You can set ``sock`` to provide a preexisting TCP socket. You may call
  :func:`socket.create_server` (not to be confused with the event loop's
  :meth:`~asyncio.loop.create_server` method) to create a suitable server
  socket and customize it.

* You can set ``start_serving`` to ``False`` to start accepting connections
  only after you call :meth:`~Server.start_serving()` or
  :meth:`~Server.serve_forever()`.

Ndeflater+   r*   i   r,   r-   )origins
extensionssubprotocolsselect_subprotocolr\   r]   r^   compressionr   r/   r0   r1   max_sizer2   r3   r   create_connectionc               6  ^ ^^^^^^^^^^^^ Tb  [        T5        US:X  a  [        T5      mOUb  [        SU 35      eTc  [        m[	        UUU	U
UTS9T l        UR                  S5      b;  UR                  SU5        [        R                  S S S:  a  UR                  ST5        SUUUUUUUUUUU UU4S	 jjn[        R                  " 5       nUR                  S
S5      (       a  UR                  " U40 UD6T l        g UR                  " UX#40 UD6T l        g )Nr   zunsupported compression: r   sslssl_handshake_timeoutr   )      ssl_shutdown_timeoutc            
     z   >^ Sn Tb        SUU4S jjn [        T	TTU TTS9nT" UTR                  T
TTTTS9mT$ )zB
Create an asyncio protocol for managing a WebSocket connection.

Nc                B   > Tc   eU TR                   L d   eT" TU5      $ rh   )r<   )r<   r   r   r   s     r>   protocol_select_subprotocolDserve.__init__.<locals>.factory.<locals>.protocol_select_subprotocol  s2    
 .999#z':'::::-j,GGr@   )r   r   r   r   r   r   r.   )r<   r   r   zSequence[Subprotocol]rp   zSubprotocol | None)r   r7   )r   r<   r   r1   r   r   r   r2   r   r   r/   r0   r   r;   r   r3   s     @r>   factoryserve.__init__.<locals>.factory  s      ( "-H,H"7H (H H &%)#>!H ++)+#'J r@   unixF)rp   r%   )r   r   
ValueErrorr%   r&   r7   get
setdefaultsysversion_inforJ   r   popcreate_unix_servercreate_server)r;   r   hostportr   r   r   r   r\   r]   r^   r   r   r/   r0   r1   r   r2   r3   r   r   kwargsr   r8   s   `   ````     ````````   r>   r6   serve.__init__  s   b #!,/)#9*EJ$8FGG$ 0+-'%
 ::e(5|D#w.!!"8-H,	 ,	 ,	\ '')::fe$$!%!8!8!KF!KD "&!3!3GT!R6!RDr@   c                "   #    U I S h  vN $  N7frh   r   r   s    r>   r   serve.__aenter__&  s     zzs   c                   #    U R                   R                  5         U R                   R                  5       I S h  vN   g  N7frh   )r7   r   r   r   s       r>   r   serve.__aexit__)  s-      	kk%%'''s   8AA Ac                >    U R                  5       R                  5       $ rh   )__await_impl__	__await__r   s    r>   r  serve.__await__4  s    ""$..00r@   c                   #    U R                   I S h  vN nU R                  R                  U5        U R                  $  N+7frh   )r   r7   r   )r;   r7   s     r>   r  serve.__await_impl__8  s4     ))) {{ *s   A >,A )r   r7   )NN),r   r   r   ru   r   
int | Noner   zSequence[Origin | None] | Noner   z'Sequence[ServerExtensionFactory] | Noner   zSequence[Subprotocol] | Noner   zNCallable[[ServerConnection, Sequence[Subprotocol]], Subprotocol | None] | Noner\   rs   r]   rt   r^   ru   r   ru   r   rm   r/   rm   r0   rm   r1   rm   r   r  r2   rn   r3   ro   r   r   r   ztype[ServerConnection] | Noner   r	   rp   rq   r   r   )rp   zGenerator[Any, None, Server])rv   rw   rx   ry   rz   r   r6   r   r   r  r  __iter__r{   r   r@   r>   r#   r#   1  s   ql  	}S 37>B59   $*"+%'&(%'&($@B49$(;?[}S>}S }S 	}S 0}S <}S 3}S}S$%}S23}S> "?}S@  A}SD #E}SF $G}SH #I}SJ $K}SN O}SP >Q}SR 2S}SV "W}SZ 9[}S^ _}S` 
a}SB(,( (( (	(
 
(1 Hr@   r#   c                     [        U 4SUS.UD6$ )a  
Create a WebSocket server listening on a Unix socket.

This function is identical to :func:`serve`, except the ``host`` and
``port`` arguments are replaced by ``path``. It's only available on Unix.

It's useful for deploying a server behind a reverse proxy such as nginx.

Args:
    handler: Connection handler. It receives the WebSocket connection,
        which is a :class:`ServerConnection`, in argument.
    path: File system path to the Unix socket.

T)r   path)r#   )r   r
  r   s      r>   r$   r$   B  s    & 9t$9&99r@   c                     U u  p[        U[        5      =(       a    [        U[        5      $ ! [        [        4 a     gf = fNF)rP   rr   	TypeErrorr   )credentialsusernamepasswords      r>   is_credentialsr  X  sD    G( (C(FZ#-FF z" s   - A A c                  ^ ^^ USL TSL :X  a  [        S5      eUb  [        U5      (       a  [        [        [        [        4   U5      /nOv[        U[        5      (       aS  [        [        [        [        [        [        4      U5      5      n[        S U 5       5      (       d  [        SU 35      eO[        SU 35      e[        U5      mSU4S jjmTc   e      SUU 4S jjnU$ )	a  
Factory for ``process_request`` to enforce HTTP Basic Authentication.

:func:`basic_auth` is designed to integrate with :func:`serve` as follows::

    from websockets.asyncio.server import basic_auth, serve

    async with serve(
        ...,
        process_request=basic_auth(
            realm="my dev server",
            credentials=("hello", "iloveyou"),
        ),
    ):

If authentication succeeds, the connection's ``username`` attribute is set.
If it fails, the server responds with an HTTP 401 Unauthorized status.

One of ``credentials`` or ``check_credentials`` must be provided; not both.

Args:
    realm: Scope of protection. It should contain only ASCII characters
        because the encoding of non-ASCII characters is undefined. Refer to
        section 2.2 of :rfc:`7235` for details.
    credentials: Hard coded authorized credentials. It can be a
        ``(username, password)`` pair or a list of such pairs.
    check_credentials: Function or coroutine that verifies credentials.
        It receives ``username`` and ``password`` arguments and returns
        whether they're valid.
Raises:
    TypeError: If ``credentials`` or ``check_credentials`` is wrong.
    ValueError: If ``credentials`` and ``check_credentials`` are both
        provided or both not provided.

Nz/provide either credentials or check_credentialsc              3  6   #    U H  n[        U5      v   M     g 7frh   )r  ).0items     r>   	<genexpr>basic_auth.<locals>.<genexpr>  s     I8H~d++8Hs   zinvalid credentials argument: c                \   >  TU    n[        R                  " X!5      $ ! [          a     gf = fr  )KeyErrorhmaccompare_digest)r  r  expected_passwordcredentials_dicts      r>   check_credentials%basic_auth.<locals>.check_credentials  s;    $4X$>! &&'8CC  s    
++c                  >#     UR                   S   n [        U5      u  pET" XE5      n[        U[        5      (       a
  UI Sh  vN nU(       dD  U R                  [        R                  R
                  S5      n[        T5      UR                   S'   U$ X@l        g! [         aG    U R                  [        R                  R
                  S5      n[        T5      UR                   S'   Us $ f = f! [         aG    U R                  [        R                  R
                  S5      n[        T5      UR                   S'   Us $ f = f N7f)z
Perform HTTP Basic Authentication.

If it succeeds, set the connection's ``username`` attribute and return
:obj:`None`. If it fails, return an HTTP 401 Unauthorized responss.

AuthorizationzMissing credentials
zWWW-AuthenticatezUnsupported credentials
NzInvalid credentials
)rZ   r  rE   rS   rT   UNAUTHORIZEDr   r   r   rP   r   r  )	r   rN   authorizationrX   r  r  valid_credentialsr  realms	          r>   r\   #basic_auth.<locals>.process_request  s>    	#OOO<M	!:=!IH .hA'33&7 7 !)),,'H 4PPU3VH/0O&?  	!)),,'H 4PPU3VH/0O	  	!)),,+H 4PPU3VH/0O	 !8sS   EB C/ "EEAEAC,)E+C,,E/AE =E?E  E)r  rr   r  rr   rp   r   )r   r%   rN   r   rp   zResponse | None)r   r  r   tuplerr   rP   r   listallr  dict)r%  r  r  credentials_listr\   r  s   ` `  @r>   r'   r'   a  s   P 	t!2d!:;JKK+&& $U38_k BCX..#D%S/)BK$PQI8HIII"@ NOO J <[MJKK 01	D (((,$,, 
, ,\ r@   rh   )r   r   r
  ru   r   r	   rp   zAwaitable[Server])r  r	   rp   r   ) NN)r%  rr   r  z2tuple[str, str] | Iterable[tuple[str, str]] | Noner  z3Callable[[str, str], Awaitable[bool] | bool] | Nonerp   zACallable[[ServerConnection, Request], Awaitable[Response | None]])9
__future__r   rJ   r  rS   r   r   r   collections.abcr   r   r   r   typesr   typingr	   r
   r   
exceptionsr   extensions.baser   extensions.permessage_deflater   framesr   rZ   r   r   r   http11r   r   r   r<   r   r   r   r7   r   r   r   r   r   compatibilityr    r   r!   r"   __all__r%   r&   r#   r$   r  r'   r   r@   r>   <module>r8     s    "      
 D D  & & & 4 L  
 / . . . # @ @ * -v3z v3rL! L!`
N Nf :::
: : 	:,G FJMQnnCn Kn G	nr@   