libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] MHD_create_post_processor failed for a GET request w


From: Helin Wang
Subject: Re: [libmicrohttpd] MHD_create_post_processor failed for a GET request with body
Date: Sat, 17 Nov 2012 16:21:18 -0800

Hi Christian,

Thanks for your response.
I did more tests, seems post processor can be created but won't be called if I did not specify encoding. post processor can't be created if I use GET. Event more, with GET (curl -d 'data' -G), *upload_data_size will always be 0.
Anyway, as you said, parse myself should be the best solution. I am using it, with POST (*upload_data_size will always be 0 with GET). So I found my way, thanks:)

Hi Christian, and everyone,

There is another issue blocking me now.
I am using threading model MHD_USE_SELECT_INTERNALLY, if I sleep 3s in the answer function.
And I give 5 concurrent requests, they will get their own response at same time (after 15s), rather than a response sequence of 3s, 3s, 3s, 3s, 3s.
My question is can I "flush" and how to "flush"?

code sample:

daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL,
                             &answer_to_connection, NULL, MHD_OPTION_END);

answer_to_connection (void *cls, struct MHD_Connection *connection, ...)
{
  const char *page = "<html><body>Hello, browser!</body></html>";
  struct MHD_Response *response;

  sleep(3);

  response =
    MHD_create_response_from_buffer (strlen (page), (void *) page,
    MHD_RESPMEM_PERSISTENT);
  ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
  MHD_destroy_response (response);

  return ret;
}



On Sat, Nov 17, 2012 at 3:58 PM, Christian Grothoff <address@hidden> wrote:
Dear Helin,

Sending data with a GET request is, eh, unusual.  Have you considered using PUT?  In any case, I suspect it should kind-of work nevertheless (but of course I didn't try this). The PostProcessor not working is most likely because it didn't understand your data encoding.  You can either manipulate the connection headers on the server side to tell it, or --- especially as your GET-with-data is likely non-standard in many ways --- just parse 'upload_data' yourself!  You don't need a PostProcessor to access upload data (just make sure you set *upload_data_size to 0 if you're done, and expect it to arrive possibly incrementally).

If you need further help, it would likely be useful if you could post exactly what you're sending to the HTTP server and also what your HTTP GET handler code looks like.

Happy hacking!

Christian


On 11/17/2012 10:30 PM, Helin Wang wrote:
Hi,

I am sending a HTTP body to microhttpd with GET, I did not use POST because
this request will not change my server state, so I want to stick to GET's
implication.

But MHD_create_post_processor returned null for this request. I know this
is reasonable, because it is a post processor rather than a get processor.

Is there any walk around?

Many thanks,
Harry





reply via email to

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