Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

HttpServerApi HostName Problem (ERROR 400)

$
0
0

Hello,

I'm programming a WebService in C++. My Client uses WinHttp and my server uses HttpServerApi.

I already developed an easy part of my client which runs correctly with a IIS Server. Now I'm programming my server on remote machine:

ulRetCode =HttpInitialize(HttpApiVersion, HTTP_INITIALIZE_SERVER, NULL);if(ulRetCode != NO_ERROR)
       wprintf(L"HttpInitialize failed with %lu \n", ulRetCode);

  ulRetCode =HttpCreateHttpHandle(&hReqQueue,0);if(ulRetCode != NO_ERROR)
       wprintf(L"HttpInitialize failed with %lu \n", ulRetCode);

    ulRetCode =HttpAddUrl(hReqQueue, L"http://localhost:1025/", NULL);if(ulRetCode != NO_ERROR)
        wprintf(L"HttpAddUrl failed with %lu \n", ulRetCode);

I'm launching one request from my client or an IE, and I've got this result "HTTP 1.1 400 BAD REQUEST, the request Hostname is invalid".


I also use WIreShark to anlayse I/O of my remote PC and I receive (client side) request well, but the response of my Server is "Request HosName Invalid" without enter in my software :/. Where is the problem ??? :)


GET / HTTP/1.1 \r\nHost: IP:Port\r\nUser-Agent:Mozilla/5.0(Windows NT 6.3; WOW64; rv:30.0)Gecko/20100101Firefox/30.0\r\nAccept: text/html, appplication.......Accept-Language:......Accept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\n
\r\n[Full request URI: http://IP@:Port/][HTTP request 1/1][Responsein frame:182]
HTTP/1.1400BadRequest\r\nContent-Type: text/html; charset=us-ascii\r\nServer:Microsoft-HTTPAPI/2.0\r\nDate:...Connection: close\r\n........Line-based text data: text/html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">\r\n<HTML><HEAD><TITLE>BadRequest</TITLE>\r\n<META HTTP-EQUIV="Content-Type" Content="Text/html; charset=us-ascii"></HEAD>/r/n<BODY><h2>Bad Request - Invalid Hostname</h2>\r\n<hr><p>HTTP Error 400. The request hostname is invalid.</p>\r\n</BODY></HTML>\r\n

Help me please :)



Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>