Sorry for longish title, but I feel that this post should be googlable. I happened to spend just too much time looking for this recently. In case you don't know how HttpListener works, I suggest reading this tutorial. If you are interested only in POST handling, here's the snippet:
from System.IO import StreamReader
from System.Web import HttpUtility
# Having HttpListenerContext in context
body = context.Request.InputStream
encoding = context.Request.ContentEncoding
reader = StreamReader(body, encoding)
nameValuePairs = HttpUtility.ParseQueryString(reader.ReadToEnd(), encoding)
# nameValuePairs contains now
# a dictionary-like object ready for further processing
2 comments:
You are my hero! I searched the last hour for something like this.
Post a Comment