Solved

Explanation about CInternetSession headers

Posted on 2001-06-21
2
460 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 118
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 423
Problem to open Excel file 15 128
x-bar in Google Sheets 2 50
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now