Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access (Newest One): Pulling Data out of a MS SQL DB 1 45
Issue testing the Class Library 4 48
WPF issue with Trigger 2 96
windbg taking it's time 32 79
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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