I’m in the process of embedding a small web server into my program. It’s relatively simple – only needs to serve up raw html files and javascript.
I have some async networking code I can use to get the basic plumbing. But are there any readily available libraries that can understand http?
I just need to be able to parse the http request to extract the path, query string, post variables and to be able to respond accordingly.
No need for SSL or cookies or authentication.
I tried a couple of web-server libraries but were not satisfied, mostly because they use worker threads that make interaction with the UI of the program annoying.
Ideally, I just want a library that would take some http request string\stream and give me back a structure or object.
I think that HttpListener might do what you want.
EDIT: (added code sample just in case)
Here’s a little code to show how you can use it (using async methods).
and then in
ContextCallback(IAsyncResult result)Take a look at HttpListenerContext for details on what you have available to you, but the main one will probably be the
Requestproperty.