Hiroyuki Ikezoe
ikezo****@users*****
Wed Jan 24 20:40:22 JST 2007
Index: kazehakase/src/net/kz-http.c diff -u kazehakase/src/net/kz-http.c:1.84 kazehakase/src/net/kz-http.c:1.85 --- kazehakase/src/net/kz-http.c:1.84 Sun Dec 31 21:16:24 2006 +++ kazehakase/src/net/kz-http.c Wed Jan 24 20:40:22 2007 @@ -1032,11 +1032,11 @@ KzHTTP *http; GIOStatus iostatus = G_IO_STATUS_NORMAL; GIOChannel *iochannel; - gchar *command; + gchar *command, *tmp_ua; const gchar *method = methods[0]; gsize n; - gchar *URL; - gchar *host_header; + gchar *URL, *host_header, *user_agent = NULL; + gboolean override = FALSE; KzHTTPPrivate *priv = KZ_HTTP_GET_PRIVATE (data); http = KZ_HTTP(data); @@ -1097,10 +1097,15 @@ priv->hostname, priv->port); #endif + KZ_CONF_GET("Global", "override_user_agent", override, BOOL); + if (override) + user_agent = KZ_CONF_GET_STR("Global", "user_agent"); + tmp_ua = user_agent ? user_agent : "Kazehakase/"VERSION; /* Send GET command */ if (priv->method == KZ_HTTP_METHOD_POST) { gchar *c_len; + if (priv->post_data) c_len = g_strdup_printf("%d", strlen(priv->post_data)); else @@ -1109,7 +1114,7 @@ command = g_strconcat(method, " ", URL, " HTTP/1.1\r\n", host_header, - "User-Agent: Kazehakase/"VERSION "\r\n", + "User-Agent: ", tmp_ua, "\r\n", "Content-Type: text/xml\r\n", "Content-Length: ", c_len, "\r\n", "Accept-Encoding: gzip,deflate\r\n", @@ -1125,7 +1130,7 @@ URL, " HTTP/1.1\r\n", host_header, "Authorization: ", priv->auth_param->string ,"\r\n", - "User-Agent: Kazehakase/"VERSION "\r\n", + "User-Agent: ", tmp_ua, "\r\n", "Accept-Encoding: gzip,deflate\r\n", "Connection: close\r\n\r\n", NULL); g_free (priv->auth_param->string); @@ -1137,12 +1142,15 @@ command = g_strconcat(method, " ", URL, " HTTP/1.1\r\n", host_header, - "User-Agent: Kazehakase/"VERSION "\r\n", + "User-Agent: ", tmp_ua, "\r\n", "Accept-Encoding: gzip,deflate\r\n", "Connection: close\r\n\r\n", NULL); } } + if (user_agent) + g_free(user_agent); + #ifdef USE_SSL if (priv->kz_ssl) {