Click here to Skip to main content
Licence 
First Posted 14 Jul 2003
Views 76,892
Bookmarked 33 times

HTTP header and source extraction tool

By | 14 Jul 2003 | Article
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

About the Author

Code4Food

Web Developer

United States United States

Member

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!


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalthank you very much! it's the thing I need. Pinmemberlb17:12 10 Apr '08  
GeneralAdding specific page support Pinmemberjdutchak2:48 3 Aug '07  
Generalit doesn't send any GET vars PinmemberLocura6668:04 20 Jun '04  
GeneralRe: it doesn't send any GET vars PinmemberDjibril5:16 29 Jun '05  
GeneralMake it more useful Pinmemberstubwang11:20 11 Nov '03  
GeneralRe: Make it more useful PinmemberCode4Food17:32 11 Nov '03  
GeneralRe: Make it more useful Pinmemberkiran_chikhale_IVI4:56 4 Sep '07  
GeneralMaking it work with PROXY Pinmemberdarthmaul23:26 21 Jul '03  
GeneralRe: Making it work with PROXY PinmemberCode4Food8:56 22 Jul '03  
GeneralNice! PinmemberRavi Bhavnani5:22 15 Jul '03  
GeneralRe: Nice! PinmemberCode4Food5:32 15 Jul '03  
GeneralRe: Nice! PinmemberRavi Bhavnani5:41 15 Jul '03  
GeneralIf you are interested in writing a webserver... PinmemberCode4Food20:15 14 Jul '03  
GeneralRe: If you are interested in writing a webserver... PinmemberRichard Day0:42 15 Jul '03  
GeneralRe: If you are interested in writing a webserver... PinmemberCode4Food5:14 15 Jul '03  
GeneralRe: If you are interested in writing a webserver... PinmemberChristoph Lederer5:36 15 Jul '03  
GeneralRe: If you are interested in writing a webserver... PinmemberCode4Food6:40 15 Jul '03  
GeneralRe: If you are interested in writing a webserver... PinmemberHugo Hallman2:10 15 Jul '03  
GeneralRe: If you are interested in writing a webserver... PinmemberCode4Food5:19 15 Jul '03  
GeneralServer code and client code PinmemberETA20:47 16 Jul '03  
GeneralRe: Server code and client code PinmemberCode4Food5:15 17 Jul '03  
GeneralRe: If you are interested in writing a webserver... PinmemberMarcus Carey10:48 31 Jan '05  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 15 Jul 2003
Article Copyright 2003 by Code4Food
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid