Live data from Hacker News

Nweb: a tiny, safe web server (static pages only)

ibm.com

31–40 of 63 posts

Re: Nweb: a tiny, safe web server (static pages only)

#31
If I had infinite time and patience, I'd tinker with this to show the differences in socket code, specifically with the approaches outlined in the C10k document.

Although it was largely unfinished, the approach outlined in C10m would be interesting to see implemented here (via the intel user-space driver).

Re: Nweb: a tiny, safe web server (static pages only)

#33
post #13

Earlier quoted context omitted.

This is hardly in the category of "lightweight and secure", but for impromptu stuff, this Ruby+Rack one-liner serves directory listings and static files from the current directory: ruby -e 'require "rack"; include Rack; \ Server.start :app => Directory.new(".", \ Static.new(nil, :urls => ["/"], :root => "."))'

python -m SimpleHTTPServer

the minimal Ruby equivalent would be

    ruby -run -ehttpd .
Here's a handy snippet for bashrc:

    function S {
      ruby -run -ehttpd . -p${1-8080}  # default to port 8080 unless given as parameter
    }

Re: Nweb: a tiny, safe web server (static pages only)

#34
post #17
post #13

Earlier quoted context omitted.

python -m SimpleHTTPServer

although that server is very horrible

What's wrong with it? Honestly, I don't know. I know Python probably isn't a great choice for performance reasons, but anything else? It's super easy to build off and configure. Seems fine for a beginner (which I admittedly am; hence my asking).

Re: Nweb: a tiny, safe web server (static pages only)

#35
post #5

I am always on the look out for a small, lightweight and secure web server for impromptu file sharing. Right now I use publicfile from djb.[^1] My only complaint is that there is no debian package for publicfile so I have to build my own package. I would love to find an equivalent (ftp not necessary) daemon that is included in debian. Is anyone aware of a something in debian repos that I am overlooking? [^1]: http://…

http://smarden.org/pape/Debian/unofficial/why.html

DJB appears to have changed the license to public domain, but at some point in the past there was a license that prohibited distribution of binaries from modified source. There's still the request that the paths not be changed to comply with the FHS.

DJB has strong opinions about the construction and distribution of software. So do quite a lot of debian people. These views are incompatible.

Re: Nweb: a tiny, safe web server (static pages only)

#36
post #5

I am always on the look out for a small, lightweight and secure web server for impromptu file sharing. Right now I use publicfile from djb.[^1] My only complaint is that there is no debian package for publicfile so I have to build my own package. I would love to find an equivalent (ftp not necessary) daemon that is included in debian. Is anyone aware of a something in debian repos that I am overlooking? [^1]: http://…

This is hardly in the category of "lightweight and secure", but for impromptu stuff, this Ruby+Rack one-liner serves directory listings and static files from the current directory: ruby -e 'require "rack"; include Rack; \ Server.start :app => Directory.new(".", \ Static.new(nil, :urls => ["/"], :root => "."))'

This is mine:

    #!/bin/bash
    unlink /Library/WebServer/Documents
    ln -s "$(pwd)" /Library/WebServer/Documents
    echo "http://localhost/ mounted on $(pwd)"
Of course, it's only "lightweight" in as far as you already have Apache installed and running.

Re: Nweb: a tiny, safe web server (static pages only)

#37
post #17

Earlier quoted context omitted.

although that server is very horrible

Works fine for some tests, but it's single threaded. If you need concurrency: twistd -no web --path=.

Perhaps, but the use case it usually finds is "I need a webserver, here. Now."

Python is nearly always installed, and that depends on nothing but the standard library. You can stick an alias in your dotfiles (I have, it's called "serve-this") and not have to worry about having twisted¹ getting to wherever your dotfiles get put. (I distribute my dotfiles over git/github, so it's really easy to move them around. More work to get Twisted.)

¹Or Ruby… or Go…

Re: Nweb: a tiny, safe web server (static pages only)

#38
post #11

I want to learn a bit about web servers and I think that study the source code of a functional one may worth more than try to build something from scratch at first glance. Since I'm seeing too many comments on the security issues of this particular project, can you guys recommend something more reliable? Thanks in advance. Edit: I "know" C and C++ and would like to remain in one of these languages, if it's not asking…

If you care about security then C and C++ are out of the game, specially if there is a team of different skill sets involved.

Having said this, have a look at Wt and Poco

http://www.webtoolkit.eu/wt

http://pocoproject.org

Re: Nweb: a tiny, safe web server (static pages only)

#39
post #20
post #19

Adding to what everyone else has said, this also "how not" to write socket code; for instance, the assumption that you can read a whole HTTP request "in one go" with a single large read call is false. Also, casting function calls to (void) is nonsensical. You can perhaps forgive the sprintf() call because, AIX. (Believe it or not, there was a time when snprintf was a portability problem). You can't forgive the log()…

> Also, casting function calls to (void) is nonsensical. Does extremely pedantic C require the results of function calls to be used? I know the correct way to mark a variable as unused is to cast it to void, but I'm not sure if you're supposed to do that for function return values as well.

Nothing about the cast is "required". However, it's good practice because the cast explicitly acknowledges the function has a return value that we're throwing out. Looking at the following function call:

    (void)create_widget(&widget);
It's clear that `create_widget` returns some value -- it's probably an error code that tells us whether the widget creation was successful. The source code here says "I know this function returns an important value, but I'm going to disregard it here". This could be useful for debugging if you find that, for example, an error condition is being handled improperly (e.g. "oh, we're obviously throwing out the return value of this function, which we shouldn't be doing"). This function call is much less informative:

    create_widget(&widget);

Re: Nweb: a tiny, safe web server (static pages only)

#40
post #35
post #5

I am always on the look out for a small, lightweight and secure web server for impromptu file sharing. Right now I use publicfile from djb.[^1] My only complaint is that there is no debian package for publicfile so I have to build my own package. I would love to find an equivalent (ftp not necessary) daemon that is included in debian. Is anyone aware of a something in debian repos that I am overlooking? [^1]: http://…

http://smarden.org/pape/Debian/unofficial/why.html DJB appears to have changed the license to public domain, but at some point in the past there was a license that prohibited distribution of binaries from modified source. There's still the request that the paths not be changed to comply with the FHS. DJB has strong opinions about the construction and distribution of software. So do quite a lot of debian people. These…

The page you linked to was last updated 11+ years ago. Notice the discussion of qmail|ucspi|djbdns-installer packages? They are not around anymore, you can install qmail/ucspi/daemontools etc. There is even djbdns and the debian tweaked + community patches version known as dbndns. Yes djb and debian devs are quite opinionated, but I do not think that is the reason that publicfile is not in debian despite the fact that so many other djb packages are.

I think the reason is low demand largely due to the fact that gnome-desktop depends on gnome-user-share (AKA: apache).

Post reply on HN