#NEWLINE# def _read_response( self , curl_output ) : #NEWLINE# #INDENT# self . response = Response ( ) #NEWLINE# meta = curl_output [ curl_output . rfind ( b'\n\n' ) : ] #NEWLINE# meta = meta . decode ( 'ascii' ) #NEWLINE# meta = json . loads ( meta ) #NEWLINE# size_header = meta [ 'size_header' ] #NEWLINE# size_download = meta [ 'size_download' ] #NEWLINE# headers = curl_output [ 0 : size_header ] #NEWLINE# body = curl_output [ size_header : ( size_header + size_download ) ] #NEWLINE# headers = headers . decode ( 'ascii' ) #NEWLINE# headers = headers . split ( '\r\n' ) #NEWLINE# for i in range ( len ( headers ) ) : #NEWLINE# #INDENT# header = headers [ i ] . upper ( ) #NEWLINE# if ( header and ( '100 CONTINUE' not in header ) ) : #NEWLINE# #INDENT# headers = headers [ i : ] #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# status_line = headers [ 0 ] #NEWLINE# try : #NEWLINE# #INDENT# ( protocol , status , reason ) = status_line . split ( ' ' , 2 ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# print ( curl_output ) #NEWLINE# self . message = 'Unable to read response. Response may have times out.' #NEWLINE# self . success = False #NEWLINE# return #NEWLINE# #UNINDENT# self . response . protocol = protocol #NEWLINE# self . response . status = int ( status_line ) #NEWLINE# self . response . reason = reason #NEWLINE# for header in headers [ 1 : ] : #NEWLINE# #INDENT# if ( ':' in header ) : #NEWLINE# #INDENT# ( key , value ) = header . split ( ':' , 1 ) #NEWLINE# self . response . headers . append ( ( key . strip ( ) , value . strip ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . response . body = self . _read_body ( body ) #NEWLINE# self . success = True