Solved

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

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

13 Experts available now in Live!

Get 1:1 Help Now