C
cerr
Hi,
Why does this code:
#!/usr/bin/python
import urllib2
from binascii import hexlify, unhexlify
host = "localhost"
uri="/test.php"
data ="\x48\x65\x6C\x6C\x6F\x57\x6F\x72\x6C\x64" #Hello World
url="http://{0}{1}?f=test".format(host, uri)
req = urllib2.Request(url, data,{'Content-Type': 'application/octet-stream'})
req.get_method = lambda: 'PUT'
response = urllib2.urlopen(req, 120)
retval = response.read()
print "RETVAL "+retval
return me this:
../post.py
Traceback (most recent call last):
File "./post.py", line 13, in <module>
response = urllib2.urlopen(req, 120)
File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 398, in open
req = meth(req)
File "/usr/lib/python2.7/urllib2.py", line 1116, in do_request_
'Content-length', '%d' % len(data))
I don't get it, what's going on here?
Thank you!
Why does this code:
#!/usr/bin/python
import urllib2
from binascii import hexlify, unhexlify
host = "localhost"
uri="/test.php"
data ="\x48\x65\x6C\x6C\x6F\x57\x6F\x72\x6C\x64" #Hello World
url="http://{0}{1}?f=test".format(host, uri)
req = urllib2.Request(url, data,{'Content-Type': 'application/octet-stream'})
req.get_method = lambda: 'PUT'
response = urllib2.urlopen(req, 120)
retval = response.read()
print "RETVAL "+retval
return me this:
../post.py
Traceback (most recent call last):
File "./post.py", line 13, in <module>
response = urllib2.urlopen(req, 120)
File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 398, in open
req = meth(req)
File "/usr/lib/python2.7/urllib2.py", line 1116, in do_request_
'Content-length', '%d' % len(data))
I don't get it, what's going on here?
Thank you!