<s> class HTTPError ( Exception ) : pass <EOL> class HTTPRequest ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , path = None , method = None , host = None ) : <EOL> """<STR_LIT>""" <EOL> self . path = path <EOL> self . method = method <EOL> self . host = host <EOL> self . headers = [ ] <EOL> self . _body = None <EOL> def add_header ( self , key , value ) : <EOL> """<STR_LIT>""" <EOL> self . headers . append ( ( key , value ) ) <EOL> def _set_body ( self , body ) : <EOL> if body is not None : <EOL> assert type ( body ) == str <EOL> self . add_header ( '<STR_LIT>' , len ( body ) ) <EOL> self . _body = body <EOL> def _get_body ( self ) : <EOL> return self . _body <EOL> body = property ( _get_body , _set_body , doc = '<STR_LIT>' ) <EOL> class HTTPResponse ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . headers = [ ] <EOL> self . status = '<STR_LIT>' <EOL> self . iter = None <EOL> @ property <EOL> def status_code ( self ) : <EOL> """<STR_LIT>""" <EOL> return int ( self . status . split ( ) [ <NUM_LIT:1> ] ) <EOL> @ property <EOL> def status_reason ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . status . split ( ) [ <NUM_LIT:2> ] <EOL> def get_header ( self , key , default = None ) : <EOL> """<STR_LIT>""" <EOL> key = key . lower ( ) <EOL> for ( _key , value ) in self . headers : <EOL> if key == _key . lower ( ) : <EOL> return value <EOL> return default <EOL> def add_header ( self , key , value ) : <EOL> """<STR_LIT>""" <EOL> self . headers . append ( ( key , value ) ) <EOL> @ property <EOL> def body ( self ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' . join ( list ( self . iter ) ) <EOL> def __iter__ ( self ) : <EOL> return iter ( self . iter ) <EOL> from concurrence . http . server import WSGIServer <EOL> from concurrence . http . client import HTTPConnection </s>
