1 2 3 4 5 6 7 8 9 10 11 12 13 |
from httplib import HTTPConnection def put_message(archive_name, file_obj): connection = HTTPConnection('localhost', 8435) connection.request('POST', 'foo', file_obj.read()) response = connection.getresponse() data = response.read() if response.status == 400: raise Exception('wtf') elif response.status == 200: return else: raise Exception('!!') |