6
by Aaron Bentley
Use constants. |
1 |
import httplib |
4
by Aaron Bentley
Initial test. |
2 |
|
3 |
def put_message(archive_name, file_obj): |
|
6
by Aaron Bentley
Use constants. |
4 |
connection = httplib.HTTPConnection('localhost', 8435) |
8
by William Grant
A little bit of server. |
5 |
connection.request('POST', '/archive/%s' % archive_name, file_obj.read()) |
4
by Aaron Bentley
Initial test. |
6 |
response = connection.getresponse() |
7 |
data = response.read() |
|
6
by Aaron Bentley
Use constants. |
8 |
if response.status == httplib.BAD_REQUEST: |
5
by Aaron Bentley
Actual fake service working. |
9 |
raise Exception('wtf') |
6
by Aaron Bentley
Use constants. |
10 |
elif response.status == httplib.CREATED: |
5
by Aaron Bentley
Actual fake service working. |
11 |
return
|
12 |
else: |
|
13 |
raise Exception('!!') |