HTTP parsing using C++

M

mthread

Hi,
I am writing a HTTP parser using C++. I am in the initial
stage where I have received the TCP data in a buffer(a void* pointer).
I need to parse the data available in this buffer. Kindly let me know
what is the best way to move forward.
 
R

Ron AF Greve

Hi,

First read up on the protocol. Do you really have all data. HTTP allows data
to be sent in two modes as one block and in parts so make sure you have the
complete page. After there are several ways if you want to implement the
complete protocol you have quite some work to do. However a simple
implementation might just get cookies and stuff from the header (which is
reasonably simple) looking for form data etc. Also make sure you are at
least able to interpret different codes that the server might send you such
as object relocated (i.e. you get an url back and have to parse that url
instead).

I you got this far you at least got the basics right and might do things as
login to a server and act on simple responses.

Unnecesarry to say that a complete implementation is not a simple task
(although the process is straight forward by just implementing everything in
the http spec.)

Regards, Ron AF Greve

http://www.InformationSuperHighway.eu
 
R

red floyd

mthread said:
Hi,
I am writing a HTTP parser using C++. I am in the initial
stage where I have received the TCP data in a buffer(a void* pointer).
I need to parse the data available in this buffer. Kindly let me know
what is the best way to move forward.
Google it. What research have you done on your own?
 
J

Juha Nieminen

mthread said:
Hi,
I am writing a HTTP parser using C++. I am in the initial
stage where I have received the TCP data in a buffer(a void* pointer).
I need to parse the data available in this buffer. Kindly let me know
what is the best way to move forward.

The best way to move forward is to search for a library someone has
already made, rather than reinventing the wheel.
 
J

Jorgen Grahn

You could have parsed some of it and acted on it already at this stage
-- could be an hour or a day earlier, if the resource is large and the
connection slow. But of course, many applications don't need that.
The best way to move forward is to search for a library someone has
already made, rather than reinventing the wheel.

And the second best is to first decide what interface you need the
parser to provide. I haven't looked around, but this is an example
from another language:

http://docs.python.org/library/basehttpserver.html

But maybe that interface isn't enough for handling "chunked encoding"
or whatever the more exotic HTTP variants are called.

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,167
Messages
2,570,910
Members
47,453
Latest member
MadelinePh

Latest Threads

Top