Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Explanation about CInternetSession headers

Posted on 2001-06-21
2
Medium Priority
?
503 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
baston earned 150 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

705 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