jump to navigation

Generic HTTP server for KDE March 29, 2010

Posted by Vitor Boschi in vitor-planetkde.

Some time ago I decided to write a file sharing app for kde, and then began hunting for some server already implemented in the libs. To my surprise, besides the fact that I found some HTTP server implementations (KGet, KTorrent and Amarok all use this in some way), none of them were  suitable for my needs :/. Their main problem is the way these servers gets the content to be served: all data must be sent at once, within a single function call. This is great when you only serve small data, but I bet you wouldn’t like to serve a multi gigabyte (common case for my app) file using a server like them.

With no server in hands, I began my own implementation, which supports large transfers without eating all system memory. This is somewhat like file reading: you fetch just a small chunk of data at a time, process it, and only then you request more data. This is a bit harder than reading everything at once, but also a lot more scalable. So I got a working server and a working application (kpws, in playground -> utils), and the I found another application, Kepas, which does almost the same thing I just wrote.

This made me stop my own app for a while, because I think KDE will benefit from having a single HTTP server implementation , just like it have a client one, and I’d like to write it as a GSoC project, but first I need to gather some feedback from the other developers, specially the ones from the applications I cited here. Do you think this will improve security, performance, maintainability and code reuse? Would it be a good GSoC project?

I am going to Akademy-BR



1. hendi - March 29, 2010

I always though GSoC’s purpose was to help and motivate students on (one of) their first contributions to FLOSS instead of defering projects of experienced hackers until during GSoC to earn some bucks …

Vitor Boschi - March 29, 2010

This is my first contribution of this kind. Before this, I just sent bug reports to KDE. The said application was started a few time ago and I just got a svn account.

2. Jernej - March 29, 2010

from the page:
…..It runs on Linux and other Unix-like operating systems as well as Microsoft Windows (under Cygwin) where it can be controlled with the Lighty Tray program which integrates into the system tray…

wrap it nicely and it can be the generic httpd for kde

Vitor Boschi - March 29, 2010

I created this post to help choosing the best solution, and this is a possible solution. Thanks for your feedback.

Upside: already working and high performance
Downside: Would add another dependency to softwares using it, and may not be as flexible/easy to implement as a Qt/KDE implementation

3. Sven - March 29, 2010

There is kepas (kpf), which is a mini-http server. It lacks some IMHO essential features for a http Server that is used to share documents on the local LAN or internet from within a desktop, like user/password restrictions according to HTTP 1.1 Digest Access Authentication. But it is a start and easy to set-up. UPnP may also be something it could support via KDE’s frameworks.

4. Jason - March 29, 2010

Check out libqxt’s QxtWeb stuff. They already have one. What really is needed though is a way to use one common server and add your own handler to the mix. Like the idea that with GET /XXXX/YYYY, you can add a handler YYYY for your app XXXX and handle other HTTP verbs as well. The your app need only register itself as a plugin to the server.

5. Joris Guisson - March 29, 2010

Actually, KTorrent’s http server does not send all data at once, that would block the main loop, it uses QSocketNotifier. But I have never tried to send a multi gigabyte file with it, and I’m sure some modifications would be needed to do that.

But a generic standards compliant HTTP server library could be very useful for KTorrent (even though we have one which is good enough for our needs)

6. Gustavo Noronha - March 29, 2010

I know dependency on GNOME-related technologies is usually frowned upon, but perhaps you should consider using libsoup. It has a fully-featured HTTP/1.1 server implementation with a very nice API, and should be easy to use/wrap in Qt.

It is also improving at a fast pace these days, because it is used as the network backend for WebkitGTK+, and some of those improvements also benefit the server side.

7. bbigras - March 29, 2010

Does Kepas support uploads?

During college I was using http://www.rejetto.com/hfs/ and it was very handy to be able to receive files from people while hosting the http server.

Vitor Boschi - March 30, 2010

Oh.. I know this one. This is the application which made me start with KDE development. HFS is a windows only application (yes.. it also works on wine) that I missed so much in Linux.
I’m not sure whetever it supports or not uploads, but this is a must IMHO.

8. Chris - March 30, 2010

Instead of writing your own from scratch have a look at libmicrohttpd (“GNU libmicrohttpd is a small C library that is supposed to make it easy to run an HTTP server as part of another application.”)


It’s written in C and actively developed so building a Qt wrapper around it surely would be easier than writing your own server.


9. René - March 30, 2010

It would be nice to have WebDav support. Which is HTTP plus PUT method. So one can upload files. Of course more infrastructure is needed than, like access rights, passwords etc. Windows and OSX has WebDav support out of the box.

Vitor Boschi - March 30, 2010

I’m not sure there will be time to implement WebDAV support on a GSoC, but I can add it after gsoc is over. Also, there are ways to upload file using only HTTP.

10. herupriadi - June 30, 2010

thanks for ur tutorial 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: