From: Jeremy Laine Date: Sun, 18 May 2008 14:42:41 +0000 (+0000) Subject: oestats-client.bbclass: switch to multipart/form-data (prepare for sending logs) X-Git-Tag: Release-2010-05/1~6895 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2162b48ef6c5a33e22e497e509a7c0763b42760;p=openembedded.git oestats-client.bbclass: switch to multipart/form-data (prepare for sending logs) --- 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