
    9i                     L    S r SSKrSSKrSSKJrJr  SSKJr  SSKJ	r	  S r
S rg)ze
This module provides general http handler functions for processing http responses from CA services.
    N)compatutils)BceClientError)BceServerErrorc                     U R                  5       nU(       aT  [        R                  " U5      n[        R                  " U[
        R                  S9UR                  S'   X!R                  S'   U R                  5         g)a  If the body is not empty, convert it to a python object and set autoscaling the value of
response.body. http_response is always closed if no error occurs.

:param http_response: the http_response object returned by HTTPConnection.getresponse()
:type http_response: http.HTTPResponse

:param response: general response object which will be returned to the caller
:type response: baidubce.BceResponse

:return: always true
:rtype bool
)object_hookresultraw_dataT)	readr   convert_to_stringjsonloadsr   dict_to_python_object__dict__close)http_responseresponsebodys      _/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/baidubce/services/ca/ca_handler.pyparse_json_listr      sc     D''-&*jj5C^C^&_(#(,*%    c                    U R                   S-  [        R                  R                  S-  :X  a  gU R                   S-  [        R                  R                  S-  :X  a  [        S5      eU R                  5       nU(       d;  [        U R                  UR                  R                  S9nU R                   Ul        Ue[        R                  " [        R                  " U5      5      n[!        U5      nSU;   a  US   b  US   nSnSU;   a  US   b  US   nUR                  R                  nSU;   a  US   b  US   n[        XVUS	9nU R                   Ul        Ue)
a*  If the body is not empty, convert it to a python object and set autoscaling the value of
response.body. http_response is always closed if no error occurs.

:param http_response: the http_response object returned by HTTPConnection.getresponse()
:type http_response: http.HTTPResponse

:param response: general response object which will be returned to the caller
:type response: baidubce.BceResponse

:return: false if http status code is 2xx, raise an error otherwise
:rtype bool

:raise baidubce.exception.BceClientError: if http status code is NOT 2xx
d   Fs#   Can not handle 1xx http status code)
request_idmessage	Exceptioncoder   )r   r   )statushttpclientOKCONTINUEr   r   r   reasonmetadatabce_request_idstatus_coder   r   r   r   str)r   r   r   bse
error_dictr   r   r   s           r   parse_errorr*   .   s@    s"dkknn&;;s"dkk&:&:c&AACDDD]11h>O>O>^>^_'..	F44T:;J*oGJ:i#8#DY'D
6 2 >&!""11Jz!j&>&J-



CC#**CO
Ir   )__doc__http.clientr   r   baidubcer   r   baidubce.exceptionr   r   r   r*    r   r   <module>r0      s%      " - -,&r   