libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] problems with callack replies


From: Viktor Paramonov
Subject: [libmicrohttpd] problems with callack replies
Date: Wed, 29 Apr 2020 14:55:40 +0200

I use the following sequence of commands:

MHD_Response* resp = MHD_create_response_from_callback (
            MHD_SIZE_UNKNOWN, DEFAULT_BLOCK_SIZE, 
            asyncReplyCallback, c, asyncReplyCleaner );
MHD_add_response_header (c->mConnection, "Content-Type", "application/json" );
MHD_queue_response ( c->mConnection,  MHD_HTTP_OK , resp );
MHD_destroy_response (resp);    

The callback function does approx. the following:

<1 or more times: copy data to provided buffer and return data length >
return MHD_CONTENT_READER_END_OF_STREAM; /* when data is finished */

In general this code works, but with problems:
1. Despite the library adds the "Transfer-encoding: chunked", there is no chunk formatting in data. All, what is returned from callback, is transmitted "as is".
2. The response header is not set. (Content-Type) 
3. The browser does not know, when data is finished. It shows that this connection is loading forever. The _javascript_ object XmlHttpRequest never gets the state "ready". I have impression, that this connection (this socket) will be never reused by browser for subsequent requests.

Is there any way to handle the reply from callback properly? 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]