Solved

Explanation about CInternetSession headers

Posted on 2001-06-21
2
468 Views
Last Modified: 2013-11-20
I need a clear explanation about the Headers in the CInternetSession which comes under CHttpConnection::AddRequestHeaders.

I need to download a HTML file from the HTTP server.
0
Comment
Question by:sunsrigod
2 Comments
 

Accepted Solution

by:
baston earned 50 total points
ID: 6214352
Hi,

The request headers are a bunch of data your browser (or application) sends along with the page request.
It basically helps the server identify the capabilities of your browser and the type of data it can accept.
Let's see the most common ones (the ones I use):

"User-Agent" - Identifies the program/client to the server, mostly for statistics purpose.

"Accept-Language" - tells the server the type of language you accept or can deal with.

"Accept-Encoding" - the file encoding your browser accept.

"Connection" - tells the server whether to keep the connection open or to treat every request as a seperate one. this is usually set to  "Keep-Alive".

"Accept" - type of files you accept, it's divided to type (like "text", "image","application") and the extension, like ("jpeg","gif","plain") to form pairs: "image/jpeg", "text/html" etc.

Request headers are very simple to use. just define the ones you wish to include in the request, seperating them with CRLF and attach them using AddRequestHeaders() to your request.
It looks something like this:

----------------------------------------------
CString szAllInAll =
_T("Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/x-comet, */*\rAccept-Language: he,en;q=0.5\rContent-Type: application/x-www-form-urlencoded\rAccept-Encoding: gzip, deflate\rUser-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 98)\rConnection: Keep-Alive\r");

CHttpFile *pFile;

// Opening CInternetSession...
// Getting the connection..
// opening the CHttpFile

pFile->AddRequestHeaders(szAllInAll,HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD);

pFile->SendRequest();

(I used MSIE 5.01 headers)
--------------------------------------------------
that's it! pretty strait forward.
for more info: http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html

Asaf
0
 

Author Comment

by:sunsrigod
ID: 6214961
thank U Asaf
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
repeatSeparator  java  challenge 13 58
canBalance challenge 34 104
Capture logon name 13 100
Problem to App source 6 89
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question