Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

webserver: decouple different webserver capabilities into handlers #706

merged 13 commits into from Mar 27, 2012


None yet
2 participants

Montellese commented Feb 19, 2012

These changes decouple different capabilities we built into our webserver (like HTTP API, JSON-RPC, VFS access etc) which are currently all handled in CWebServer::AnswerToConnection(), into different classes called handlers which all implement the same interface IHTTPRequestHandler. This makes it a lot easier to maintain those different handlers without having to fear that changing something in one of them affects the behaviour of one of the other handlers (which is currently possible). Most webservers (like Apache HTTPd etc) use handlers to allow to extend them without having to mess around with the webserver implementation itself.

The whole handler-system is based on registering the existing handlers (with a priority) in the CWebserver instance. Then everytime a new HTTP request comes through libmicrohttpd the webserver works through the list of the registered handlers and calls IHTTPRequestHandler::CheckHTTPRequest() which will return whether this handler wants/is able to handle the current request. If that's the case a new instance of that specific handler is requested (because HTTP requests are handled in different and possibly concurrent threads) and then the webserver lets the handler do with the request whatever he wants by calling IHTTPRequestHandler::HandleHTTPRequest(). It then waits for that method to finish and then retrieves the HTTP response code and the data of the response from the instance before destroying it and sending the HTTP response to the requester.

IMO this will also make it easier to add new functionality (e.g. the image resizing posted in PR #92). Based on this work I have also started implementing a handler which will be able to execute python scripts through our webserver (which would allow more powerful webinterfaces for XBMC).

I have tested these changes on win32 and linux (ubuntu) but it's not tested on osx and requires changes to osx/ios project files.


Montellese commented Feb 20, 2012

@jmarshallnz: I removed the unneeded include of JobManager.h in WebServer.cpp. Thanks for the hint.

@Montellese Montellese was assigned Mar 23, 2012


Montellese commented Mar 25, 2012

Another rebase to fix conflicts with the merging of the websocket PR.

@Memphiz I just merged the conflicts in the osx/ios/atv2 project files but no clue if that's possible and if it still works. Could you please check for me? Thanks a lot.

@Montellese Montellese added a commit that referenced this pull request Mar 27, 2012

@Montellese Montellese Merge pull request #706 from Montellese/webserver_decoupling
webserver: decouple different webserver capabilities into handlers

@Montellese Montellese merged commit adff927 into xbmc:master Mar 27, 2012

@tru tru added a commit to plexinc/plex-home-theater-public that referenced this pull request Nov 12, 2013

@tru tru Add a clear filters button to filter sublists.
Related to #706

The season picker presents seasons unnaturally sorted, resulting in a drop down menu like this:

Season 1
Season 10
Season 11
Season 2

We need to write our own natural string sorter to ensure numbers are sorted in ascending (or descending) order numerically, after 'Season'.


Montellese replied May 11, 2014

What does this have to do with this commit?

And feature requests and bug reports belong to the forums.

It was the last commit to affect this part of the code. I don't have a forum account and don't plan to create one, if you could make a thread for the issue I'd be grateful.

@Forage Forage referenced this pull request Jul 18, 2014


Tvshow multipaths parentid #4977

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment