Click here to Skip to main content
14,695,499 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I get this info in C++. I'm using a sniffer and I'm getting the TCP header info but I need to get this a s well. Any help appreciated. Thanks.

HTTP/1.1 200 OK
Date: Wed, 05 Nov 2003 10:46:04 GMT
Server: Apache/1.3.28 (Unix) PHP/4.2.3
Content-Location: CSS2-REC.en.html
Vary: negotiate,accept-language,accept-charset
TCN: choice
P3P: policyref=http://www.w3.org/2001/05/P3P/p3p.xml
Cache-Control: max-age=21600
Expires: Wed, 05 Nov 2003 16:46:04 GMT
Last-Modified: Tue, 12 May 1998 22:18:49 GMT
ETag: "3558cac9;36f99e2b"
Accept-Ranges: bytes
Content-Length: 10734
Connection: close
Content-Type: text/html; charset=iso-8859-1
Content-Language: en
Posted

1 solution

There was a discussion on StackOverflow that might interest you: http://stackoverflow.com/questions/2257172/http-header-in-a-packets[^].

I'm not sure what you are up to, but reading the HTT protocol on TCP packet level should prove to be quite entertaining ( though only if you are a masochist ). I suspect you want to trigger some action when certain header values are encountered. To make sure we understand what you are trying to achieve it would be best to explain your goals.

Using proxies could be an alternative if you have any control over the network architecture. I'm affirmative this is not some kind of intrusion attempt?

Cheers!

—MRB
   
Comments
Member 7766180 21-Aug-11 17:37pm
   
Thank you for the response. I thought it would be fairly easy to do this. I'm sniffing the packets now and I kinda have them reassembled, I just want to get the content-type from an tcp/http download. Thats it. Nothing neferious going on, just my way of passing time! :) I don't want to use proxies, windump, or wireshark. Want to do this seperate from them.
Manfred Rudolf Bihy 22-Aug-11 9:49am
   
How are you doing the sniffing then, WinPCap perhaps?
If you already have the data reassembled from the packets what problems are you encountering?
Member 7766180 22-Aug-11 17:50pm
   
Well, being an infant to all of this...I think this is what I have. I'm using WSA Sockets and I am getting all of the IP header, TCP header info. When the data portion of the packet prints I can see content-type, etc. My problem is that I need to isolate the content-type from the http header so that I can run logic off of it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900