Your IP : 216.73.216.213
B
;��]wU � @ s� d Z eZddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZm
Z
ddlmZ ddlmZ dd lmZ dd
lmZ ddlmZ eekr�dd
� Zdd� Zndd
� Zdd� ZG dd� d�ZG dd� d�ZG dd� d�Zee�G dd� d��ZdgZ dS )zo
An implementation of
U{Python Web Server Gateway Interface v1.0.1<http://www.python.org/dev/peps/pep-3333/>}.
� )�exc_info)�warn)�implementer)�blockingCallFromThread)�reraise�Sequence)�Failure)� IResource)�NOT_DONE_YET)�INTERNAL_SERVER_ERROR)�Loggerc C s t | t�r| S | �d�S dS )z�
Convert C{string} to an ISO-8859-1 byte string, if it is not already.
@type string: C{str}/C{bytes} or C{unicode}
@rtype: C{str}/C{bytes}
@raise UnicodeEncodeError: If C{string} contains non-ISO-8859-1 chars.
z
iso-8859-1N)�
isinstance�str�encode)�string� r �C/opt/alt/python37/lib64/python3.7/site-packages/twisted/web/wsgi.py�_wsgiString- s
r c C s | S )z�
Return C{string} as is; a WSGI string is a byte string in Python 2.
@type string: C{str}/C{bytes}
@rtype: C{str}/C{bytes}
r )r r r r �_wsgiStringToBytes; s r c C s( t | t�r| �d��d�S | �d�S dS )as
Convert C{string} to a WSGI "bytes-as-unicode" string.
If it's a byte string, decode as ISO-8859-1. If it's a Unicode string,
round-trip it to bytes and back using ISO-8859-1 as the encoding.
@type string: C{str} or C{bytes}
@rtype: C{str}
@raise UnicodeEncodeError: If C{string} contains non-ISO-8859-1 chars.
z
iso-8859-1N)r
r r �decode)r r r r r E s
c C s
| � d�S )z�
Convert C{string} from a WSGI "bytes-as-unicode" string to an
ISO-8859-1 byte string.
@type string: C{str}
@rtype: C{bytes}
@raise UnicodeEncodeError: If C{string} contains non-ISO-8859-1 chars.
z
iso-8859-1)r )r r r r r V s
c @ s. e Zd ZdZe� Zdd� Zdd� Zdd� ZdS ) �_ErrorStreama�
File-like object instances of which are used as the value for the
C{'wsgi.errors'} key in the C{environ} dictionary passed to the application
object.
This simply passes writes on to L{logging<twisted.logger>} system as
error events from the C{'wsgi'} system. In the future, it may be desirable
to expose more information in the events it logs, such as the application
object which generated the message.
c C s^ t |t�sDttkr.td|t|�jf td� ntd|t|�jf ��| jj |dd|fd� dS )aG
Generate an event for the logging system with the given bytes as the
message.
This is called in a WSGI application thread, not the I/O thread.
@type data: str
@raise TypeError: On Python 3, if C{data} is not a native string. On
Python 2 a warning will be issued.
z+write() argument should be str, not %r (%s))�categoryz)write() argument must be str, not %r (%s)ZwsgiT)�systemZisError�messageN)
r
r �bytesr �type�__name__�UnicodeWarning� TypeError�_log�error)�self�datar r r �writeq s
z_ErrorStream.writec C s | � d�|�� dS )a�
Join the given lines and pass them to C{write} to be handled in the
usual way.
This is called in a WSGI application thread, not the I/O thread.
@param iovec: A C{list} of C{'\n'}-terminated C{str} which will be
logged.
@raise TypeError: On Python 3, if C{iovec} contains any non-native
strings. On Python 2 a warning will be issued.
� N)r# �join)r! Ziovecr r r �
writelines� s
z_ErrorStream.writelinesc C s dS )z�
Nothing is buffered, so flushing does nothing. This method is required
to exist by PEP 333, though.
This is called in a WSGI application thread, not the I/O thread.
Nr )r! r r r �flush� s z_ErrorStream.flushN) r �
__module__�__qualname__�__doc__r r r# r&