How does a httpPlatformHandler program get posted data?

Roland Smith 1 Reputation point
2022-06-15T01:30:09.54+00:00

I wrote a httpPlatformHandler server app using C++ and Winsock functions. When the URL is called with GET from a browser, recv returns headers. If I call the URL from a program that does a GET and includes data, I see the Content-Length header but no data. If I do a POST, recv returns nothing.

I need to know how my app can access posted data.

Another issue is that when calling from a browser, occasionally recv returns nothing or a bad gateway error.

If Winsock expert would like to look at the code, I can post that.

Internet Information Services
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,454 questions
0 comments No comments
{count} votes

8 answers

Sort by: Most helpful
  1. Roland Smith 1 Reputation point
    2022-06-17T22:49:01.74+00:00

    The data being sent with the GET is only 16 characters. My buffer is 1024 and all the headers total about 350.

    Do you have a code example you can point me to? When I use POST, recv returns nothing.

    0 comments No comments

  2. Xiaopo Yang - MSFT 11,661 Reputation points Microsoft Vendor
    2022-06-24T09:15:02.863+00:00

    recv returns -1 and WSAGetLastError returns WSAEWOULDBLOCK which means no data is queued to be read from the socket.
    The problem should be the request is read partially or hasn't been read when the execution run through while.
    For a simply solution, according to socket_dumb_http, you can check the last "\r\n\r\n" to see whether the request is transmitted completely or not.

    0 comments No comments

  3. Roland Smith 1 Reputation point
    2022-06-26T02:34:55.387+00:00

    I have it working but the forum won't let me post any details.