ruạṛ
a [��f� � @ s� d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z ddl mZ ddlm Z mZmZmZmZ dd lmZmZ dd lmZ ddlmZ ejZejZe� ZG dd � d e�ZG dd� de�ZdS )zResponse class.� N)�PY2)�string_types)�http_cookies)�DEFAULT_MEDIA_TYPE)�Handlers)�format_content_disposition�format_header_value_list�format_range�header_property�is_ascii_encodable)� dt_to_http�TimezoneGMT)�encode)�encode_valuec @ s& e Zd ZdZdZeZd8dd�Zedd� �Z e j dd� �Z d d � Zdd� Zd9dd�Z dd� Zdd� Zdd� Zdd� Zdd� Zdd� Zd:dd�Zedde�Zed d!e�Zed"d#e�Zed$d%�Zed&d'e�Zed(d)�Zed*d+e �Z!ed,d-e�Z"ed.d/e#�Z$ed0d1e�Z%ed2d3�Z&d;d4d5�Z'de(fd6d7�Z)dS )<�ResponseaO Represents an HTTP response to a client request. Note: `Response` is not meant to be instantiated directly by responders. Keyword Arguments: options (dict): Set of global options passed from the API handler. Attributes: status (str): HTTP status line (e.g., '200 OK'). Falcon requires the full status line, not just the code (e.g., 200). This design makes the framework more efficient because it does not have to do any kind of conversion or lookup when composing the WSGI response. If not set explicitly, the status defaults to '200 OK'. Note: Falcon provides a number of constants for common status codes. They all start with the ``HTTP_`` prefix, as in: ``falcon.HTTP_204``. media (object): A serializable object supported by the media handlers configured via :class:`falcon.RequestOptions`. See :ref:`media` for more information regarding media handling. body (str or unicode): String representing response content. If set to a Unicode type (``unicode`` in Python 2, or ``str`` in Python 3), Falcon will encode the text as UTF-8 in the response. If the content is already a byte string, use the :attr:`data` attribute instead (it's faster). data (bytes): Byte string representing response content. Use this attribute in lieu of `body` when your content is already a byte string (``str`` or ``bytes`` in Python 2, or simply ``bytes`` in Python 3). See also the note below. Note: Under Python 2.x, if your content is of type ``str``, using the `data` attribute instead of `body` is the most efficient approach. However, if your text is of type ``unicode``, you will need to use the `body` attribute instead. Under Python 3.x, on the other hand, the 2.x ``str`` type can be thought of as having been replaced by what was once the ``unicode`` type, and so you will need to always use the `body` attribute for strings to ensure Unicode characters are properly encoded in the HTTP response. stream: Either a file-like object with a `read()` method that takes an optional size argument and returns a block of bytes, or an iterable object, representing response content, and yielding blocks as byte strings. Falcon will use *wsgi.file_wrapper*, if provided by the WSGI server, in order to efficiently serve file-like objects. stream_len (int): Expected length of `stream`. If `stream` is set, but `stream_len` is not, Falcon will not supply a Content-Length header to the WSGI server. Consequently, the server may choose to use chunked encoding or one of the other strategies suggested by PEP-3333. context (dict): Dictionary to hold any data about the response which is specific to your app. Falcon itself will not interact with this attribute after it has been initialized. context_type (class): Class variable that determines the factory or type to use for initializing the `context` attribute. By default, the framework will instantiate standard ``dict`` objects. However, you may override this behavior by creating a custom child class of ``falcon.Response``, and then passing that new class to `falcon.API()` by way of the latter's `response_type` parameter. Note: When overriding `context_type` with a factory function (as opposed to a class), the function is called like a method of the current Response instance. Therefore the first argument is the Response instance itself (self). options (dict): Set of global options passed from the API handler. ) �body�data�_headers�_cookies�status�stream� stream_len�context�options�__dict__Nc C sN d| _ i | _|r|nt� | _d | _d | _d | _d | _d | _d | _ | � � | _d S )Nz200 OK)r r �ResponseOptionsr r �_mediar r r r �context_typer )�selfr � r �s/sparta/input/_build_configuration/image_build+validate/lib/bmcenv/lib64/python3.9/site-packages/falcon/response.py�__init__� s zResponse.__init__c C s | j S �N)r �r r r r �media� s zResponse.mediac C s>