0

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?

Biffen
  • 6,249
  • 6
  • 28
  • 36
KESHAV K
  • 63
  • 10
  • 1
    It makes sense that `WinHttpOpenRequest` (or any other conformant library) would not allow you to specify an illegal version. There is no HTTP 1.3. If you want more control over the content of an HTTP request, I suggest you drop down to the Winsock level and write and send your own HTTP request by hand. Asking for library recommendations is off-topic for StackOverflow. – Remy Lebeau Feb 20 '18 at 08:22
  • I'm sorry for asking library recommendations and thank you on the other hand. I shall write an HTTP request from the socket level and try the same. – KESHAV K Feb 20 '18 at 09:53

0 Answers0