skokal01 / mongoose

Automatically exported from code.google.com/p/mongoose
0 stars 0 forks source link

bound URIs have no access to PUT request data #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
when a PUT request is handed off to a bound URI handler, the request data
is not included.  The following change rectifies the situation:

static void
analyze_request(struct mg_connection *conn)
{
...
    if ((cb = find_callback(conn->ctx, FALSE, uri, -1)) != NULL) {
        if (!strcmp(ri->request_method, "POST") || !strcmp(ri->request_method,
"PUT"))
            handle_request_body(conn, -1);

        cb->func(conn, &conn->request_info, cb->user_data);
    } else

Original issue reported on code.google.com by streambr...@gmail.com on 11 May 2009 at 8:39

GoogleCodeExporter commented 9 years ago
Hmm. Accessing PUT data, that sounds odd to me.
Could you elaborate more on your use case, please?
How do you setup a handler (do you know the name of PUT-ted files beforehand or 
do
you use wildcard), and why do you need to handle PUT request in the first place?

Original comment by valenok on 27 May 2009 at 4:17

GoogleCodeExporter commented 9 years ago
I am implementing a REST interface in an embedded application.  The put data 
needs to
be interpreted as an action to be executed inside of the embedded app. 

See http://en.wikipedia.org/wiki/Representational_State_Transfer for more on 
REST.

Original comment by streambr...@gmail.com on 22 Jan 2010 at 9:19

GoogleCodeExporter commented 9 years ago
You can process PUT totally in embedded mode - just catch MG_NEW_REQUEST event,
and do mg_read().

Original comment by valenok on 7 Sep 2010 at 7:39

GoogleCodeExporter commented 9 years ago
Are you saying something like this?

myEventHandler(...)
{
...
if( !strcmp(ri->request_method, "PUT") )
   mg_read(conn, buf, 1024);
...
}

This does not work as the code inside mg_read skips everything for non-POST 
request. So it PUT doesn't work for PUT.

  if (strcmp(conn->request_info.request_method, "POST") == 0 &&
      conn->consumed_content < conn->content_len) {

Original comment by amolta...@gmail.com on 23 Sep 2010 at 4:44