On Feb 25, 9:39*am, Sachin <svh...@gmail.c omwrote:
I want to write a http response parser in c.
The W3C gives a fairly comprehensive specification for the HTTP
protocol on its website. In general, you accept a command line that
starts with "GET", "HEAD", "PUT" and so on, usually followed by the
URL path (like "/~user/index.html" or something similar) then usually
followed by something like "HTTP/1.1" then a CR and LF. After that
you have sub-commands like: "Connection : Keep-Alive\r\n" or "Cookie:
<...>\r\n" or "Content-Encoding: <...>\r\n" or "User-Agent: <...>\r\n"
and so on to give more information about the command. Its then
followed by an additional CR, LF and then possible content parameters
(encoded according to earlier parameters; typically www-url-encoding
or MIME if its a form post of some kind).
I've never written a HTTP server, only the client. But I cannot
imagine that its really all that difficult. There must be available
source out there somewhere.
plz help me out...how should i proceed in writing the code... what
functions should i use....
For just the parser part, you don't need to go beyond string
comparisons. Regular expression parsers such as PCRE might help a
little bit, but I don't think that it makes a big difference.
If you want to do this in practice, I would recommend that you also
install Apache and Ethereal (both are available for the most relevant
operating systems.) That way you can observe the protocol response
for a real HTTP server.
--
Paul Hsieh
http://www.pobox.com/~qed/ http://bstring.sf.net/