-1

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

quamrana
  • 37,849
  • 12
  • 53
  • 71
jerams
  • 113
  • 1
  • 2
  • 8
  • Do you know how does HTTP packet looks like ? http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol – oneat Feb 13 '10 at 10:44
  • yes, i surely know what it looks like..the problem i have is how to get data or the http header in a packet being retrieve by the winpcap.. – jerams Feb 13 '10 at 13:00

2 Answers2

1

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.

Macke
  • 24,812
  • 7
  • 82
  • 118
0

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
  • 12,749
  • 1
  • 27
  • 35