2
* Copyright (C) 2008, 2009 Nokia Corporation.
4
* Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
5
* <zeeshan.ali@nokia.com>
7
* This file is part of Rygel.
9
* Rygel is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* Rygel is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public License
20
* along with this program; if not, write to the Free Software Foundation,
21
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
* HTTP request handler interface.
29
internal abstract class Rygel.HTTPRequestHandler: GLib.Object {
30
public Cancellable cancellable { get; set; }
32
// Add response headers.
33
public virtual void add_response_headers (HTTPRequest request)
34
throws HTTPRequestError {
35
var mode = request.msg.request_headers.get ("transferMode.dlna.org");
37
// FIXME: Is it OK to just copy the value of this header from
38
// request to response? All we do to entertain this header is to
39
// set the priority of IO operations.
40
request.msg.response_headers.append ("transferMode.dlna.org", mode);
43
// Yes, I know this is not the ideal code to just get a specific
44
// string for an HTTP header but if you think you can come-up with
45
// something better, be my guest and provide a patch.
46
var didl_writer = new GUPnP.DIDLLiteWriter (null);
47
var didl_item = didl_writer.add_item ();
48
var resource = this.add_resource (didl_item, request);
49
var tokens = resource.protocol_info.to_string ().split (":", 4);
50
assert (tokens.length == 4);
52
request.msg.response_headers.append ("contentFeatures.dlna.org",
56
// Create an HTTPResponse object that will render the body.
57
public abstract HTTPResponse render_body (HTTPRequest request)
58
throws HTTPRequestError;
60
protected abstract DIDLLiteResource add_resource (DIDLLiteItem didl_item,
62
throws HTTPRequestError;