[gupnp] Propagate User-Agent to message from cache
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp] Propagate User-Agent to message from cache
- Date: Sun, 30 Apr 2017 14:58:58 +0000 (UTC)
commit 484014e9de2a8b86995197d15973885d6d8ce621
Author: Jens Georg <mail jensge org>
Date: Sun Apr 30 16:57:45 2017 +0200
Propagate User-Agent to message from cache
Instead of just populating the cache, also update the message if there isn't
one in the message but we have a cached value.
libgupnp/gupnp-context.c | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/libgupnp/gupnp-context.c b/libgupnp/gupnp-context.c
index 47a5cb6..9d30f4b 100644
--- a/libgupnp/gupnp-context.c
+++ b/libgupnp/gupnp-context.c
@@ -902,7 +902,7 @@ host_path_handler (G_GNUC_UNUSED SoupServer *server,
SoupMessage *msg,
const char *path,
G_GNUC_UNUSED GHashTable *query,
- G_GNUC_UNUSED SoupClientContext *client,
+ SoupClientContext *client_ctx,
gpointer user_data)
{
char *local_path, *path_to_open;
@@ -913,6 +913,7 @@ host_path_handler (G_GNUC_UNUSED SoupServer *server,
GError *error;
HostPathData *host_path_data;
const char *user_agent;
+ const char *host;
orig_locales = NULL;
locales = NULL;
@@ -940,9 +941,25 @@ host_path_handler (G_GNUC_UNUSED SoupServer *server,
user_agent = soup_message_headers_get_one (msg->request_headers,
"User-Agent");
- update_client_cache (host_path_data->context,
- soup_client_context_get_host (client),
- user_agent);
+ host = soup_client_context_get_host (client_ctx);
+
+ /* If there was no User-Agent in the request, try to guess from the
+ * discovery message and put it into the response headers for further
+ * processing. Otherwise use the agent to populate the cache.
+ */
+ if (user_agent == NULL) {
+ GSSDPClient *client = GSSDP_CLIENT (host_path_data->context);
+
+ user_agent = gssdp_client_guess_user_agent (client, host);
+
+ if (user_agent != NULL) {
+ soup_message_headers_append (msg->response_headers,
+ "User-Agent",
+ user_agent);
+ }
+ } else {
+ update_client_cache (host_path_data->context, host, user_agent);
+ }
/* Construct base local path */
local_path = construct_local_path (path, user_agent, host_path_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]