Solved

Explanation about CInternetSession headers

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

11 Experts available now in Live!

Get 1:1 Help Now