I'm aware that WinHttpOpenRequest
specifies the version of the HTTP that the application should be using to communicate with the server.
I want to see how the server behaves if I send a request with an unsupported HTTP version. But the function automatically changes the version to HTTP/1.1. It isn't mentioned anywhere in the documentation that we can use only specific versions.
#include <serverutils.h>
void main()
{
HINTERNET hSession=NULL,hRequest=NULL,hConnect=NULL;
BOOL bResults=FALSE;
hSession = WinHttpOpen(L"Sample Program", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,WINHTTP_NO_PROXY_NAME,WINHTTP_NO_PROXY_BYPASS, 0 );
if(hSession)
{
hConnect = WinHttpConnect(hSession,L"172.21.206.60",8080,0);
}
if(hConnect)
{
hRequest = WinHttpOpenRequest(hConnect,L"GET",L"/",L"HTTP/1.3" ,WINHTTP_NO_REFERER,WINHTTP_DEFAULT_ACCEPT_TYPES,0);
}
if(hRequest)
{
bResults = WinHttpSendRequest(hRequest,WINHTTP_NO_ADDITIONAL_HEADERS,0,WINHTTP_NO_REQUEST_DATA,0,0,0);
}
if(bResults)
{
bResults = WinHttpReceiveResponse(hRequest,NULL);
}
getRequestHeaders(hRequest);
_getch();
}
Is there anyway with which I can send a request with an unsupported HTTP version? If WinHTTP does not support this, will any other library do this?