Solved

"Connection: Close" header for WinInet in C++

Posted on 2002-03-30
2
1,644 Views
Last Modified: 2013-12-03
I want to add the "Connection: Close" header in a request to be sent to a server.  However, it doesn't seem to be sent using the WinInet functions (and the connection is kept alive).  When I try the "Connection: Keep-Alive" header, it is sent for sure.

For example, I have:

string headers;

headers = "Connection: Close\r\n"; // this header is not sent
// headers = "Connection: Keep-Alive\r\n"; // this header is sent

// hRequest defined as HINTERNET, returned from HttpOpenRequest()
HttpAddRequestHeaders(hRequest, headers.c_str(), headers.length(), HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);

// This also won't send "Connection: Close"
// HttpSendRequest(hRequest, headers.c_str(), headers.length(), NULL, 0);


I've only tried HttpAddRequestHeaders() and HttpSendRequest().  Is there another function, flag, etc. to forcefully add the "Connection: Close" header to a request?
0
Comment
Question by:mersenes
2 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 6907909
This is not needed.  Just DON'T send the "Keep-Alive" request.  The non-keep-alive behavior is the default.
0
 

Author Comment

by:mersenes
ID: 6908227
I simply omitted the "Connection" header and assumed the "non-keep-alive behavior is the default" as you said -- it now works.  Thanks!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

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

16 Experts available now in Live!

Get 1:1 Help Now