daokoder / dao-modules

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

Switching the backend of web.http #52

Closed Night-walker closed 9 years ago

Night-walker commented 9 years ago

There is one problem about Marten: it is a two years old Mongoose snapshot which hasn't seen any development all this time. Chances are high it will become a relic with time. It's OK as a temporary solution, but I wouldn't place bets on it in the long run.

Now, I've come across civetweb, which is yet another MIT-licensed Mongoose fork, but under active development. It seems to have substantially improved over its predecessor.

With few tiny modifications, I was able to build web.http with civetweb and run the server successfully. Just few source files from civetweb repository were necessary for that.

I'd say a web-server is ill-suited for the standard library at all, but as long as there is no other source of http support available, it's better to at least keep it in proper shape.

dumblob commented 9 years ago

Yes, it makes sense to switch backends. On the other hand, I don't feel a web server is ill-suited for the standard library (especially if the backend is not maintained/developed by us).

Night-walker commented 9 years ago

Web server in standard library is somewhat ill-suited because there is more then one way to implement a web server. Mongoose way of doing it cannot be declared the standard or the best one. But, as I said, the absence of generic http support in Dao makes it reasonable to maintain such a web server in the library.

Now, I think I can incorporate civetweb into web.http as soon as @daokoder approves it.

daokoder commented 9 years ago

Already done:)

Night-walker commented 9 years ago

I see you didn't waste time :) I suppose it is done then.

Night-walker commented 9 years ago

Found a problem: client side doesn't work. Trying http::Client::Get('http://localhost:8080') results in SEGFAULT (because CLIENT_Get() doesn't expect that postlen might be lesser then 0) due to the fact that recv() in mg_read() returned 0.

For now, I only know that the server goes successfully to civetweb.c:8067, delegating the work to the handler, which returns 1 (request processed). Apparently, no data is sent back at that point.

Night-walker commented 9 years ago

The problem appears to be not with civetweb -- I successfully fetched http://example.com with http::Client and checked hello-world Dao server with browser.

daokoder commented 9 years ago

There is indeed a bug. With Civetweb, mg_read() may return negative value, which wasn't the case for Mongoose/Marten.

Now fixed.

Night-walker commented 9 years ago

The problem is not with the missing postlen check (Marten actually behaves the same way, I stumbled upon this few days ago). While e.g. sample.dao server is running, trying to receive anything from it via web.http fails as recv() returns no data.

Night-walker commented 9 years ago

Damn, I must have messed with something. It is working now :)