
    9ir                     l    S r SSKrSSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  SSK
Jr  SSK
Jr  S	 rS
 rg)zf
This module provides general http handler functions for processing http responses from BCE services.
    N)str)bytes)utils)compat)BceClientError)BceServerErrorc                 &   U R                  5       nU(       aj  [        R                  " U5      nUR                  R	                  [
        R                  " U[        R                  S9R                  5        X!R                  S'   U R                  5         g)a  If the body is not empty, convert it to a python object and set as 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: httplib.HTTPResponse

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

:return: always true
:rtype bool
)object_hookraw_dataT)
readr   convert_to_string__dict__updatejsonloadsr   dict_to_python_objectclose)http_responseresponsebodys      U/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/baidubce/http/handler.py
parse_jsonr      sm     D''-  De>Y>Y!Z!c!cd(,*%    c                    U R                   S-  [        R                  R                  S-  :X  a  gU R                   S-  [        R                  R                  S-  :X  a  [        S5      eSnU R                  5       nU(       a>  [        R                  " [        R                  " U5      5      n[        US   US   US   S9nUc(  [        U R                  UR                  R                  S	9nU R                   Ul        Ue)
a$  If the body is not empty, convert it to a python object and set as 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: httplib.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 codeNmessagecode	requestId)r   
request_id)r   )statushttpclientOKCONTINUEr   r   r   r   r   r   r   reasonmetadatabce_request_idstatus_code)r   r   bser   ds        r   parse_errorr+   0   s     s"dkknn&;;s"dkk&:&:c&AACDD
CDJJv//56Qy\&	anU
{]11h>O>O>^>^_#**CO
Ir   )__doc__http.clientr!   builtinsr   r   r   baidubcer   r   baidubce.exceptionr   r   r   r+    r   r   <module>r2      s.          - -,r   