daokoder / dao-modules

Dao Standard Modules
http://daovm.net
12 stars 5 forks source link

web.http post handling problem #56

Closed Night-walker closed 9 years ago

Night-walker commented 9 years ago

The following

http::Client::Post('http://localhost:8080', 'Hello=World', 'application/x-www-form-urlencoded')

hangs with samples/sample_post.dao server. Apparently, more data is expected on either end. With http://httpbin.org/post, it works fine and I get back the decoded post data.

daokoder commented 9 years ago

Works fine for me (on Mac).

Night-walker commented 9 years ago

I run it on Ubuntu 14.04.

# client
(dao) load web.http
= none
(dao) http::Client::Post('http://localhost:8080', 'Hello=World', 'application/x-www-form-urlencoded')
= # after ~30 secs
(dao) 
# server
odanylov@odanylov-lt:~/Downloads/dao/modules$ ../bin/dao web/http/samples/sample_post.dao 
*** 1436517769.0x7fb873031740.mg_start.10274: [document_root] -> [/home/odanylov/Downloads/dao/modules/]
*** 1436517769.0x7fb873031740.mg_start.10274: [listening_ports] -> [8080]
*** 1436517769.0x7fb873031740.mg_start.10274: [num_threads] -> [4]
*** 1436517769.0x7fb873031740.mg_start.10274: [enable_keep_alive] -> [yes]
*** 1436517769.0x7fb873017700.consume_socket.9702: going idle
*** 1436517769.0x7fb872ffe700.consume_socket.9702: going idle
*** 1436517769.0x7fb872fe5700.consume_socket.9702: going idle
*** 1436517769.0x7fb873030700.consume_socket.9702: going idle
*** 1436517787.0x7fb87304f700.accept_new_connection.9879: Accepted socket 4
*** 1436517787.0x7fb87304f700.produce_socket.9849: queued socket 4
*** 1436517787.0x7fb873017700.consume_socket.9715: grabbed socket 4, going busy
*** 1436517787.0x7fb873017700.handle_request.8039: URL: /
reused = 0 1 1 0 0
*** 1436517827.0x7fb873017700.consume_socket.9702: going idle

The last line of the server log also appears after ~30 secs of hanging on the reused line.

It hangs on recv() at the client side.

Night-walker commented 9 years ago

OK, one problem was with persistent connections not supported by http::Server. Disabled them. Now I get empty result.

Night-walker commented 9 years ago

Now it seems to work... but I don't get anything beside the form. No 'POST Variable: ' + X + ' = ' + Y + '</br>\n' lines which should have been written by the server.

Night-walker commented 9 years ago

Even more interesting. Sometimes it returns the form without variables, sometimes nothing at all.

daokoder commented 9 years ago

I was mistaking, it actually didn't work for me. It seems that the problem is caused by socket closing on the server side (based on the comments where -1 was return by mg_read()). But I have no idea why this happens.

Night-walker commented 9 years ago

On Windows, POST data is returned, but in half of the attempts it also returns nothing. But the worst thing is that I am unable to reproduce this behavior while running via debugger: with GDB, everything works perfectly.

It does seem to work when tested with a browser though.

daokoder commented 9 years ago

It still does not work on Mac (works on lubuntu though), even after disabling persistent connections. I found that the problem occurs when there is no Content-Length: in the response header. I begin to believe it is a Civetweb bug, after I reproduced the bug by removing the Content-Length: part from civetweb/examples/post.c.

I also observe a few other issues only exists with the Civetweb backend, not with the Marten backend. I just started a new topic #57 to discuss if we should switch the backend back to Marten, and discussed these issues there.

Night-walker commented 9 years ago

Fixed by coming back to Marten.