Solved

Explanation about CInternetSession headers

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 56
how do i create updater to My Activex application? 3 108
wordmultiple challenge 12 170
Way to decrease size of apk file 9 133
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

710 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