Added support for Cross-site HTTP requests (CORS)

This is needed because the client is written in Javascript and practically
all user agents deny cross-site AJAX requests unless an OPTION request is
sent first, after which appropriate headers should be received before the
actual request (be it e.g. GET or POST) is sent.

This code is not tested!