How do I read the raw http post STRING. I've found several solutions for reading a parsed version of the post, however the project I'm working on submits a raw xml payload without a header. So I am trying to find a way to read the post data without it being parsed into a key => value array.
self.rfile.read(int(self.headers.getheader('Content-Length')))
will return the raw HTTP POST data as a string.
Breaking it down:
self.headers.getheader('Content-Length')
returns the content length (value of the header) as a string.self.rfile.read()
, so use the int()
function.Also, note that the header name is case sensitive so it has to be specified as 'Content-Length' only.
Edit: Apparently header field is not case sensitive (at least in Python 2.7.5) which I believe is the correct behaviour since https://www.rfc-editor.org/rfc/rfc2616 states:
Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With