<s> __author__ = '<STR_LIT>' <EOL> import os <EOL> import sys <EOL> parentdir = os . path . dirname ( os . path . dirname ( os . path . abspath ( __file__ ) ) ) <EOL> sys . path . insert ( <NUM_LIT:0> , parentdir ) <EOL> import format_type <EOL> from . . utils import parameter_helper as helper <EOL> class HttpRequest : <EOL> content_md5 = "<STR_LIT>" <EOL> content_length = "<STR_LIT>" <EOL> content_type = "<STR_LIT:Content-Type>" <EOL> def __init__ ( self , host = "<STR_LIT>" , url = "<STR_LIT:/>" , method = None , headers = { } ) : <EOL> self . __host = host <EOL> self . __url = url <EOL> self . __method = method <EOL> self . __content_type = "<STR_LIT>" <EOL> self . __content = "<STR_LIT>" <EOL> self . __encoding = "<STR_LIT>" <EOL> self . __headers = headers <EOL> self . __body = None <EOL> def get_host ( self ) : <EOL> return self . __host <EOL> def set_host ( self , host ) : <EOL> self . __host = host <EOL> def get_body ( self ) : <EOL> return self . __body <EOL> def set_body ( self , body ) : <EOL> self . __body = body <EOL> def get_url ( self ) : <EOL> return self . __url <EOL> def set_url ( self , url ) : <EOL> self . __url = url <EOL> def get_encoding ( self ) : <EOL> return self . __encoding <EOL> def set_encoding ( self , encoding ) : <EOL> self . __encoding = encoding <EOL> def get_content_type ( self ) : <EOL> return self . __content_type <EOL> def set_content_type ( self , content_type ) : <EOL> self . __content_type = content_type <EOL> def get_method ( self ) : <EOL> return self . __method <EOL> def set_method ( self , method ) : <EOL> self . __method = method <EOL> def get_content ( self ) : <EOL> return self . __content <EOL> def get_header_value ( self , name ) : <EOL> return self . __headers [ name ] <EOL> def put_header_parameter ( self , key , value ) : <EOL> if key is not None and value is not None : <EOL> self . __headers [ key ] = value <EOL> def md5_sum ( self , content ) : <EOL> return helper . md5_sum ( content ) <EOL> def set_content ( self , content , encoding , format ) : <EOL> tmp = dict ( ) <EOL> if content is None : <EOL> self . __headers . pop ( self . content_md5 ) <EOL> self . __headers . pop ( self . content_length ) <EOL> self . __headers . pop ( self . content_type ) <EOL> self . __content_type = None <EOL> self . __content = None <EOL> self . __encoding = None <EOL> return <EOL> str_md5 = self . md5_sum ( content ) <EOL> content_length = len ( content ) <EOL> content_type = format_type . RAW <EOL> if format is None : <EOL> content_type = format <EOL> self . __headers [ self . content_md5 ] = str_md5 <EOL> self . __headers [ self . content_length ] = content_length <EOL> self . __headers [ self . content_type ] = content_type <EOL> self . __content = content <EOL> self . __encoding = encoding <EOL> def get_headers ( self ) : <EOL> return self . __headers </s>
