summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Laine <jeremy.laine@m4x.org>2008-05-18 14:42:41 +0000
committerJeremy Laine <jeremy.laine@m4x.org>2008-05-18 14:42:41 +0000
commitc2162b48ef6c5a33e22e497e509a7c0763b42760 (patch)
tree255cab14bc2248e0f6092a2327bdfb9f257221ed
parentf11396765e4294339034519933c4b7d0049dd569 (diff)
oestats-client.bbclass: switch to multipart/form-data (prepare for sending logs)
-rw-r--r--classes/oestats-client.bbclass30
1 files changed, 24 insertions, 6 deletions
diff --git a/classes/oestats-client.bbclass b/classes/oestats-client.bbclass
index 661ef74a22..a57bd92bce 100644
--- a/classes/oestats-client.bbclass
+++ b/classes/oestats-client.bbclass
@@ -19,12 +19,30 @@ def oestats_getid(d):
return f.read()
def oestats_send(server, action, vars = {}):
- import httplib, urllib
-
- params = urllib.urlencode(vars)
- headers = {"Content-type": "application/x-www-form-urlencoded"}
+ import httplib
+
+ # build body
+ output = []
+ bound = '----------ThIs_Is_tHe_bouNdaRY_$'
+ for key in vars:
+ assert vars[key]
+ output.append('--' + bound)
+ output.append('Content-Disposition: form-data; name="%s"' % key)
+ output.append('')
+ output.append(vars[key])
+ output.append('--' + bound + '--')
+ output.append('')
+ body = "\r\n".join(output)
+
+ # build headers
+ headers = {
+ "User-agent": "oestats-client/0.1",
+ "Content-type": "multipart/form-data; boundary=%s" % bound,
+ "Content-length": str(len(body))}
+
+ # send request
conn = httplib.HTTPConnection(server)
- conn.request("POST", action, params, headers)
+ conn.request("POST", action, body, headers)
response = conn.getresponse()
data = response.read()
conn.close()
@@ -88,7 +106,7 @@ def oestats_task(server, d, task, status):
'revision': bb.data.getVar('PR', d, True),
'task': task,
'status': status,
- 'time': elapsed,
+ 'time': str(elapsed),
})
addhandler oestats_eventhandler