Using system.net.httpPost to send arbitrary data is not binary safe.
Only tested on 7.8.2-rc1
From the manual:
[quote]You can post arbitrary data as well, but you’ll need to specify the MIME type. The document is then returned as a string.
[/quote]
eg sending a 1x1 pixel png by way of example in the attached txt file shows the corruption of the sent data.
[attachment=0]httpPost.txt[/attachment]
For headers and data as indicated in file
#this works
import urllib2
request = urllib2.Request('http://localhost:8000/add', data=data, headers=headers)
f = urllib2.urlopen(request)
print f.read()
#this corrupts binary data
ret=system.net.httpPost("http://localhost:8000/add", headers['Content-Type'], data)
print ret
The application/octet-stream mimetype is intentional in my application.
Quick inspection seems to indicate that it has something to do with the java byte array being a signed value…eg the corruption appears to occur when the value is negative eg over 7bit.