Commit 56e4fd19 authored by Jens Georg's avatar Jens Georg

server: Guess User-Agent for item requests

This was previously not done. Some devices only send out their user-agent or
something equivalent on UPnP or even SSDP level. GSSDP and GUPnP are
maintaining a cache for that, but that does not apply for things served
directly in Rygel so we have to do that ourselves.
parent 3e0aea3d
......@@ -85,6 +85,7 @@ public class Rygel.HTTPServer : GLib.Object, Rygel.StateMachine {
context.add_server_handler (true, this.path_root, this.server_handler);
context.server.request_aborted.connect (this.on_request_aborted);
context.server.request_started.connect (this.on_request_started);
context.server.request_read.connect (this.on_request_read);
if (this.cancellable != null) {
this.cancellable.cancelled.connect (this.on_cancelled);
......@@ -198,6 +199,24 @@ public class Rygel.HTTPServer : GLib.Object, Rygel.StateMachine {
message.got_headers.connect (this.on_got_headers);
private void on_request_read (Soup.Server server,
Soup.Message message,
Soup.ClientContext client) {
var agent = message.request_headers.get_one ("User-Agent");
if (agent == null) {
var host = client.get_host ();
agent = this.context.guess_user_agent (host);
if (agent != null) {
debug ("Guessed user agent %s for %s", agent, client.get_host ());
message.request_headers.append ("User-Agent", agent);
} else {
debug ("Could not guess user agent for ip %s.", host);
private void on_got_headers (Soup.Message msg) {
if (msg.method == "POST" &&
msg.uri.path.has_prefix (this.path_root)) {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment