Click here to Skip to main content
12,396,230 members (70,536 online)
Click here to Skip to main content
Add your own
alternative version

Stats

86.2K views
2.5K downloads
33 bookmarked
Posted

HTTP header and source extraction tool

, 14 Jul 2003
Rate this:
Please Sign up or sign in to vote.
Tool to retrieve the header and source file from a URL.

Sample Image - hextract.jpg

Introduction

I created this tool in order to help facilitate my new project of creating a web server using straight Winsock2 calls. After spending a couple of hours creating it, I realized I really did not need to have this tool. However, it has given me a better understanding of the headers returned from a 'GET' statement made to the website. For fun, try entering some popular website you know of and see if it returns anything you find odd. For example, typing in 'www.redhat.com' and having the Server line return "Microsoft/IIS".

Usage

Enter the URL in the top edit box and then hit the 'Get Data' button. This will get the default document in the URL you entered and the header information as seen by your browser, and what is returned by the server. This tool would be helpful for someone building a web browser, as opposed to a web server, but it does give you a good view of the header information returned. The source file is the same as you would get from using Internet Explorer and going to "view source".

Credit

  • MSDN
  • CodeProject people from this thread, who helped me sort out my \r\n problems

Oddities

I initially tried to use the CHttpFile.Read() member function but it only wanted to read in 4KB of data. I tried setting the buffer but could not get it to read in all the data to display in the HTML source box. I had to use the ReadString() function instead and keep appending it to another data CString. If anyone can elaborate on this for me, I would be much appreciative.

Future

At this time I do not have any plans for this code just because I realized I really did not need it to write a web server. If you have any suggestions on how to upgrade the code, for a tool you would use, please let me know, as I am open to any suggestions.

History

  • 07/14/2003 - Released article and code (version 1.0)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Code4Food
Web Developer
United States United States
My real name is Sam I live in Monterey, California. I am currently unemployed - long story. I am trying to secure a job as a programmer in the Silicon Valley area of CA but so far no luck. Now with all this extra time I am writing code and learning concepts I have put off because I was too busy working Smile | :)

I have completed two of my programming goals: release software in the form of freeware, and write an article for CodeProject!

You may also be interested in...

Comments and Discussions

 
Generalthank you very much! it's the thing I need. Pin
lb10-Apr-08 17:12
memberlb10-Apr-08 17:12 
GeneralAdding specific page support Pin
jdutchak3-Aug-07 2:48
memberjdutchak3-Aug-07 2:48 
Generalit doesn't send any GET vars Pin
Locura66620-Jun-04 8:04
memberLocura66620-Jun-04 8:04 
GeneralRe: it doesn't send any GET vars Pin
Djibril29-Jun-05 5:16
memberDjibril29-Jun-05 5:16 
GeneralMake it more useful Pin
stubwang11-Nov-03 11:20
memberstubwang11-Nov-03 11:20 
GeneralRe: Make it more useful Pin
Code4Food11-Nov-03 17:32
memberCode4Food11-Nov-03 17:32 
GeneralRe: Make it more useful Pin
kiran_chikhale_IVI4-Sep-07 4:56
memberkiran_chikhale_IVI4-Sep-07 4:56 
GeneralMaking it work with PROXY Pin
darthmaul21-Jul-03 23:26
memberdarthmaul21-Jul-03 23:26 
GeneralRe: Making it work with PROXY Pin
Code4Food22-Jul-03 8:56
memberCode4Food22-Jul-03 8:56 
GeneralNice! Pin
Ravi Bhavnani15-Jul-03 5:22
memberRavi Bhavnani15-Jul-03 5:22 
GeneralRe: Nice! Pin
Code4Food15-Jul-03 5:32
memberCode4Food15-Jul-03 5:32 
GeneralRe: Nice! Pin
Ravi Bhavnani15-Jul-03 5:41
memberRavi Bhavnani15-Jul-03 5:41 
GeneralIf you are interested in writing a webserver... Pin
Code4Food14-Jul-03 20:15
memberCode4Food14-Jul-03 20:15 
GeneralRe: If you are interested in writing a webserver... Pin
Richard Day15-Jul-03 0:42
memberRichard Day15-Jul-03 0:42 
GeneralRe: If you are interested in writing a webserver... Pin
Code4Food15-Jul-03 5:14
memberCode4Food15-Jul-03 5:14 
GeneralRe: If you are interested in writing a webserver... Pin
Christoph Lederer15-Jul-03 5:36
memberChristoph Lederer15-Jul-03 5:36 
GeneralRe: If you are interested in writing a webserver... Pin
Code4Food15-Jul-03 6:40
memberCode4Food15-Jul-03 6:40 
GeneralRe: If you are interested in writing a webserver... Pin
Hugo Hallman15-Jul-03 2:10
memberHugo Hallman15-Jul-03 2:10 
GeneralRe: If you are interested in writing a webserver... Pin
Code4Food15-Jul-03 5:19
memberCode4Food15-Jul-03 5:19 
GeneralServer code and client code Pin
ETA16-Jul-03 20:47
memberETA16-Jul-03 20:47 
GeneralRe: Server code and client code Pin
Code4Food17-Jul-03 5:15
memberCode4Food17-Jul-03 5:15 
GeneralRe: If you are interested in writing a webserver... Pin
Marcus Carey31-Jan-05 10:48
memberMarcus Carey31-Jan-05 10:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 15 Jul 2003
Article Copyright 2003 by Code4Food
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid