none
WinHttp asynchronous server implementation RRS feed

  • Question

  • I need to develop a http server for sending responses to REST client requests.
    My implementation is parallel and asynchronous, based on overlapped structure.
    Everything seems good, but to manage POST requests with long body, I need to use a very long body buffer size.
    I can't retrieve the entity body with several calls to HttpReceiveRequestEntityBody, after getting the header with HttpReceiveHttpRequest.
    I found code example for synchronous behaviour, but not for asynchronous.
    I can submit my source code if you need.
    Thanks in advance<o:p></o:p>


    NewGroup MDSN Visual C++ - Roberto Farioli

    Friday, October 25, 2019 3:51 PM

All replies

  • > I can't retrieve the entity body with several calls to HttpReceiveRequestEntityBody after getting
    > the header with HttpReceiveHttpRequest.

    Why not?  That's the right way to do it.  When you say "I can't", do you mean you tried it and it didn't work, or that you don't know how to make it work?


    Tim Roberts | Driver MVP Emeritus | Providenza &amp; Boekelheide, Inc.

    Saturday, October 26, 2019 12:35 AM
  • But I don't know how big could the entity body be, so I need the way to retrieve the body with several and subsequent calls with fixed buffer size.<o:p></o:p>

    Have you a source code example to show or do you prefer I attach my one?<o:p></o:p>


    NewGroup MDSN Visual C++ - Roberto Farioli

    Monday, October 28, 2019 8:19 AM
  • Right, this is normal for TCP/IP transactions.  You keep asking for a chunk at a time until there is no more (ERROR_HANDLE_EOF).  You either process the chunks piece by piece as they come in, or you keep appending the buffer you get to some larger buffer, or if the buffer is bigger than memory, you copy it our to a file, and read it back when the transaction is over.

    Now, in many cases you can know the actual length of the body to come, by fetching the Content-Transfer-Length header, but not all server situations send that.


    Tim Roberts | Driver MVP Emeritus | Providenza &amp; Boekelheide, Inc.

    Monday, October 28, 2019 5:25 PM