summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntanas Uršulis <antanas.ursulis@gmail.com>2013-07-29 19:01:19 +0300
committerAntanas Uršulis <antanas.ursulis@gmail.com>2013-07-29 19:01:19 +0300
commit167cee2838f3b4e4c785d749e1b2366b116569ed (patch)
tree75d63207831be571d33e7157db57cc017621bbbe
parentSend only filename, not full path (diff)
downloadlog-analysis-167cee2838f3b4e4c785d749e1b2366b116569ed.tar.gz
log-analysis-167cee2838f3b4e4c785d749e1b2366b116569ed.tar.bz2
log-analysis-167cee2838f3b4e4c785d749e1b2366b116569ed.zip
Port simple_client to urllib2, so that we can set Content-Type
-rw-r--r--simple_client.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/simple_client.py b/simple_client.py
index 3abc7c9..99a4116 100644
--- a/simple_client.py
+++ b/simple_client.py
@@ -2,7 +2,7 @@
Simple submission client that forms a correct protobuf message and performs a POST
"""
-import submission_pb2, sys, urllib, os
+import submission_pb2, sys, urllib2, os
def send_submission(filenames):
submission = submission_pb2.Submission()
@@ -12,7 +12,8 @@ def send_submission(filenames):
new_file.filename = os.path.basename(f)
new_file.data = open(f, 'rb').read()
- print urllib.urlopen('http://[::1]:5000/submit', submission.SerializeToString()).read()
+ request = urllib2.Request('http://[::1]:5000/submit', submission.SerializeToString(), {"Content-Type" : "application/octet-stream"})
+ print urllib2.urlopen(request).read()
if __name__ == '__main__':
if len(sys.argv) < 2: