views:

91

answers:

2

how to retrieve the http header in a packet in c++?

any sample code or tutorials can be a big help!..

thanx!..

note: winpcap was used for the packet sniffing and these packets are already filterd to be only tcp and http/s protocols..the only problem is how to decode the packet's http header..

A: 

The C++ network library might be what you're looking for.

Check the http::parser and its parse_http_headers member function in particular. It will populate an object of type http::message with the contents of your message's header.

The lib is still under development and the documentation is scarce. Therefore, the best way to learn it seems to be by browsing the source (but don't worry, it's very readable).

Manuel
+1  A: 

If you got the header read into a buffer already use the HTTP specification.

If you need to read the header, look at ASIO or boost::asio (same lib) for a neat low-level network lib. Or, consider Qt, an entire C++ framework that supports both low and high-level networking (and much more). There are HTTP client/server classes that you can use there.

Or, open a socket() and read from it directly. Eww.

Marcus Lindblom