Add (and use) an own user-agent string, created from uuid, version (if present) and used http-library (libsoup).

merge-requests/218/head
Jens Lody 9 years ago
parent e0fb8d693d
commit 6f2113f650
  1. 11
      src/extension.js
  2. 11
      src/prefs.js

@ -147,6 +147,16 @@ const OpenweatherMenuButton = new Lang.Class({
_init: function() {
this.owmCityId = 0;
// Create user-agent string from uuid and (if present) the version
this.user_agent = Me.metadata.uuid;
if (Me.metadata.version !== undefined && Me.metadata.version.trim() !== '')
{
this.user_agent += '/';
this.user_agent += Me.metadata.version.toString();
}
// add trailing space, so libsoup adds its own user-agent
this.user_agent += ' ';
this.oldProvider = this._weather_provider;
this.oldTranslateCondition = this._translate_condition;
this.switchProvider();
@ -989,6 +999,7 @@ const OpenweatherMenuButton = new Lang.Class({
// log(new Error().fileName+':'+new Error().lineNumber+' => url = '+url);
if (_httpSession === undefined) {
_httpSession = new Soup.Session();
_httpSession.user_agent = this.user_agent;
}
let message = Soup.form_request_new_from_hash('GET', url, params);

@ -105,6 +105,16 @@ const WeatherPrefsWidget = new GObject.Class({
_init: function(params) {
this.parent(params);
// Create user-agent string from uuid and (if present) the version
this.user_agent = Me.metadata.uuid;
if (Me.metadata.version !== undefined && Me.metadata.version.trim() !== '')
{
this.user_agent += '/';
this.user_agent += Me.metadata.version.toString();
}
// add trailing space, so libsoup adds its own user-agent
this.user_agent += ' ';
this.initWindow();
defaultSize = this.MainWidget.get_size_request();
@ -608,6 +618,7 @@ const WeatherPrefsWidget = new GObject.Class({
loadJsonAsync: function(url, params, fun, id) {
if (_httpSession === undefined) {
_httpSession = new Soup.Session();
_httpSession.user_agent = this.user_agent;
}
let here = this;

Loading…
Cancel
Save