[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

HTTP parsing using C++

mthread

11/22/2008 10:51:00 AM


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.



4 Answers

Ron AF Greve

11/22/2008 12:23:00 PM

0

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.InformationSuper...

"mthread" <rjkumr@gmail.com> wrote in message
news:60293560-ce92-40ff-9453-7e1bb99dca38@t39g2000prh.googlegroups.com...
>
> 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.
>
>
>


red floyd

11/22/2008 6:18:00 PM

0

mthread wrote:
> 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?

Juha Nieminen

11/22/2008 7:43:00 PM

0

mthread wrote:
> 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.

Jorgen Grahn

11/22/2008 10:02:00 PM

0

On Sat, 22 Nov 2008 19:43:03 GMT, Juha Nieminen <nospam@thanks.invalid> wrote:
> mthread wrote:
>> 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).

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.

>> 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.

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/basehttps...

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

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se> R'lyeh wgah'nagl fhtagn!