Solved

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

Posted on 2002-03-30
2
1,673 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

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

713 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