Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions watson_developer_cloud/watson_developer_cloud_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json as json_import
import platform
import os
import requests
import sys
Expand Down Expand Up @@ -103,6 +104,12 @@ def __init__(self, vcap_services_name, url, username=None, password=None,
self.password = None
self.default_headers = None

user_agent_string = 'watson-apis-python-sdk-' + __version__ # SDK version
user_agent_string += ' ' + platform.system() # OS
user_agent_string += ' ' + platform.release() # OS version
user_agent_string += ' ' + platform.python_version() # Python version
self.user_agent_header = {'user-agent': user_agent_string}

if x_watson_learning_opt_out:
self.default_headers = {'x-watson-learning-opt-out': 'true'}

Expand Down Expand Up @@ -273,8 +280,7 @@ def request(self, method, url, accept_json=False, headers=None,

input_headers = _remove_null_values(headers) if headers else {}

headers = CaseInsensitiveDict(
{'user-agent': 'watson-developer-cloud-python-' + __version__})
headers = CaseInsensitiveDict(self.user_agent_header)
if self.default_headers is not None:
headers.update(self.default_headers)
if accept_json:
Expand Down