Live data from Hacker News

Raphters, a web framework for C

github.com

41–50 of 70 posts

Re: Raphters, a web framework for C

#41
post #37
post #11

It would be neat to see how you could possibly hook Lua into this to give you some of the flexibility of a dynamic language with the speed and small footprint of a (mostly) C app. I've been thinking of working on something like that for a while but unfortunately my C skills need a lot more work before I'd be comfortable tackling it.

Came across this the other day: Embed the Power of Lua into NginX https://github.com/chaoslawful/lua-nginx-module

There's also AbsoLUAtion for Lighttpd. Lua's a very nice, convenient language for embedding dynamic/user-configurable bits in otherwise static applications. PowerDNS and nmap use it, too. It seems to have displaced Tcl as the de facto language for embedding.

Re: Raphters, a web framework for C

#42
post #8
post #5

Earlier quoted context omitted.

Rather: response_set_status(200); response_set_header("Content-Type", "text/html"); response_write(body); response_end(); The awkwardness of which, to me, demonstrates the superiority of C++ in this regard.

That implies some global state somewhere being updated, and now you've given up on threading. This may be OK, but it's still dangerous and leaky even if you give up on threading. There are various solutions that still allow you to pass a set of closures without being particularly more ugly than anything else is in C, for instance, see http://library.gnome.org/devel/gobject/stable/chapter-signal... . C++ still ends up…

Web applications vulnerable to shell-code injection... this sounds like a security nightmare.

Re: Raphters, a web framework for C

#43
There was some issues with the code. Mostly memleaks. I think I've fixed most of them, although it was tough to do so elegantly. You may want to rethink using the START_HANDLER macro (or at least restructure it) as it makes it difficult to correctly handle errors with writing a response. I've addressed this issue in RAPHT and offered a fix. However I think I complete rework is of that subsystem is probably better.

I'm at work so I can't setup a server to test, however after summoning my inner compiler my changes seem sane. But you should look them over (check the pull on github https://github.com/DanielWaterworth/Raphters/pull/2).

I'll be around if you want to discuss a proper fix for some of the issues. Albeit it will take a pretty major rewrite.

Re: Raphters, a web framework for C

#44

Pretty cool, but if I really had to write some kind of C stuff to output web pages I suppose I'd just build it as an apache module rather than go the CGI route, there's lots of useful functions and nifty stuff within apache making it a pretty nice environment for serving stuff. (Or more probably since it's 2011, I'd try an nginx module (or lightty), although I have never looked at any of those projects code yet). Bui…

Funnily enough this was going to be my starting point into writing a C webapp. I felt that by writing a C module directly embedded in an existing web server it would allow me to leverage the request handling. Having already done bugfixes for apache C modules are work it felt the most relevant path to take. The problem I see with it though is you are bound to the webserver you write the module for. Portability would be nice.

Re: Raphters, a web framework for C

#49
post #36

Earlier quoted context omitted.

A little off-topic, but you sound familiar with libevent. I've never used either but I'm looking at gevent for a project, and I noticed that they switched to libev: http://software.schmorp.de/pkg/libev.html ... do you know what "limitations and bugs" in libevent they speak of? I poked through the mailing list for libev and couldn't find anything specific.

I've never paid much attention to libev. I've been using libevent since 2002 (it was the standard event loop at Arbor Networks, which was in Ann Arbor, where Niels Provos lived at the time). Before libevent, I used ACE_reactor to accomplish the same tasks. I prefer libevent (strongly) to ACE. I might prefer libev to libevent, but... why bother? Libevent works fine. My guess about "limitations" of libevent is that it'…

[deleted]

Re: Raphters, a web framework for C

#50
post #38

Earlier quoted context omitted.

Something like evhttp also has the benefit that you can have more than one request "in flight". FastCGI can theoretically do this, but almost no implementation supports it - and it makes e.g. writing a simple chat server much easier (one process, one thread, tons of connections, data in memory.)

The downside to doing evhttp is that he'll have to write his own request parsing (I think he's relying on Apache/CGI to do that for him now). But if you're going to do a C web framework (and... really? you sure about that?), that's probably how you should do it.

> The downside to doing evhttp is that he'll have to write his own request parsing...

Which, these days, isn't a huge deal. Both of these are decent:

https://github.com/ry/http-parser

https://github.com/mongrel/mongrel/blob/master/ext/http11/ht...

Post reply on HN