
    BTh                         d dl Z d dlZd dlmZ d dlmZmZ ddlmZm	Z	  e j                  e      Z G d d      Z G d d	e      Zy)
    N)BytesIO)	parse_qslurlparse   )CaseInsensitiveDict_is_nonsequence_iteratorc                      e Zd ZdZd Zed        Zej                  d        Zed        Zej                  d        Zd Z	ed        Z
ed	        Zed
        Zed        Zed        Zed        Zed        Zd Zd Zd Zed        Zy)Requestz,
    VCR's representation of a request.
    c                 <   || _         || _        t        |d      | _        t	        |      | _        | j                  r|j                         | _        n$| j
                  rt        |      | _        n|| _        || _	        t        j                  d| j                         y )NreadzInvoking Request %s)methodurihasattr	_was_filer   	_was_iterr   bodylistheaderslogdebug)selfr   r   r   r   s        ]/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/vcr/request.py__init__zRequest.__init__   sq     v.1$7>>		DI^^T
DIDI		'2    c                     | j                   S N)_headersr   s    r   r   zRequest.headers   s    }}r   c                 H    t        |t              st        |      }|| _        y r   )
isinstanceHeadersDictr   r   values     r   r   zRequest.headers"   s    %-&Er   c                     | j                   rt        | j                        S | j                  rt	        | j                        S | j                  S r   )r   r   _bodyr   iterr   s    r   r   zRequest.body(   s8    >>4::&&>>

##zzr   c                 T    t        |t              r|j                  d      }|| _        y )Nzutf-8)r    strencoder%   r"   s     r   r   zRequest.body0   s!    eS!LL)E
r   c                 Z    t        j                  dt        d       || j                  |<   y )NzKRequest.add_header is deprecated. Please assign to request.headers instead.   )
stacklevel)warningswarnDeprecationWarningr   )r   keyr#   s      r   
add_headerzRequest.add_header6   s'    Y	

 "Sr   c                 @    t        | j                        j                  S r   )r   r   schemer   s    r   r3   zRequest.scheme>   s    !(((r   c                 @    t        | j                        j                  S r   )r   r   hostnamer   s    r   hostzRequest.hostB   s    !***r   c                     t        | j                        }|j                  }|	 ddd|j                     }|S |S # t        $ r Y |S w xY w)Ni  P   )httpshttp)r   r   portr3   KeyError)r   	parse_urir;   s      r   r;   zRequest.portF   s\    TXX&	~~<!$b1)2B2BC t  s   ; 	AAc                 @    t        | j                        j                  S r   )r   r   pathr   s    r   r?   zRequest.pathQ   s    !&&&r   c                 h    t        | j                        j                  }t        t	        |            S r   )r   r   querysortedr   )r   qs     r   rA   zRequest.queryU   s%    TXX$$il##r   c                     | j                   S r   )r   r   s    r   urlzRequest.url[   s    xxr   c                     | j                   S r   )r3   r   s    r   protocolzRequest.protocol`   s    {{r   c                 <    d| j                    d| j                   dS )Nz
<Request (z) >)r   r   r   s    r   __str__zRequest.__str__d   s    DKK=488*A66r   c                 "    | j                         S r   )rJ   r   s    r   __repr__zRequest.__repr__g   s    ||~r   c           	          | j                   | j                  | j                  | j                  j	                         D ci c]	  \  }}||g c}}dS c c}}w )N)r   r   r   r   )r   r   r   r   items)r   kvs      r   _to_dictzRequest._to_dictj   sL    kk88II+/<<+=+=+?@41aA3@	
 	
 As   Ac                     t        di |S )N )r
   )clsdcts     r   
_from_dictzRequest._from_dictr   s    ~~r   N)__name__
__module____qualname____doc__r   propertyr   setterr   r1   r3   r6   r;   r?   rA   rE   rG   rJ   rL   rQ   classmethodrV   rS   r   r   r
   r
      s   3   ^^ 
   
[[ 
" ) ) + +   ' ' $ $
    7
  r   r
   c                   "     e Zd ZdZ fdZ xZS )r!   aY  
    There is a weird quirk in HTTP.  You can send the same header twice.  For
    this reason, headers are represented by a dict, with lists as the values.
    However, it appears that HTTPlib is completely incapable of sending the
    same header twice.  This puts me in a weird position: I want to be able to
    accurately represent HTTP headers in cassettes, but I don't want the extra
    step of always having to do [0] in the general case, i.e.
    request.headers['key'][0]

    In addition, some servers sometimes send the same header more than once,
    and httplib *can* deal with this situation.

    Furthermore, I wanted to keep the request and response cassette format as
    similar as possible.

    For this reason, in cassettes I keep a dict with lists as keys, but once
    deserialized into VCR, I keep them as plain, naked dicts.
    c                     t        |t        t        f      r|d   }| j                  j	                  |j                               }|r|d   }t        |   ||       y )Nr   )r    tupler   _storegetlowersuper__setitem__)r   r0   r#   old	__class__s       r   re   zHeadersDict.__setitem__   sO    eeT]+!HE kkoociik*a&CC'r   )rW   rX   rY   rZ   re   __classcell__)rg   s   @r   r!   r!   w   s    &	( 	(r   r!   )loggingr-   ior   urllib.parser   r   utilr   r   	getLoggerrW   r   r
   r!   rS   r   r   <module>rn      s@       , ?g!i iX(% (r   