From 5d241fd1b5d708abe96a93b73971ffc47f1de236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 7 Jan 2016 22:13:08 +0100 Subject: [PATCH] Don't set Host header manually It's taken care of by the requests module, based on the url we're posting to, so no need to juggle the host header ourselves. --- pyicloud/base.py | 1 - pyicloud/services/calendar.py | 4 ---- pyicloud/services/contacts.py | 2 -- pyicloud/services/findmyiphone.py | 2 -- pyicloud/services/ubiquity.py | 3 --- 5 files changed, 12 deletions(-) diff --git a/pyicloud/base.py b/pyicloud/base.py index ba47524..e59003d 100644 --- a/pyicloud/base.py +++ b/pyicloud/base.py @@ -57,7 +57,6 @@ class PyiCloudService(object): self.session = requests.Session() self.session.verify = verify self.session.headers.update({ - 'Host': 'setup.icloud.com', 'Origin': self._home_endpoint, 'Referer': '%s/' % self._home_endpoint, 'User-Agent': 'Opera/9.52 (X11; Linux i686; U; en)' diff --git a/pyicloud/services/calendar.py b/pyicloud/services/calendar.py index bab3ebf..1ed03f6 100644 --- a/pyicloud/services/calendar.py +++ b/pyicloud/services/calendar.py @@ -57,8 +57,6 @@ class CalendarService(object): Fetches a single event's details by specifying a pguid (a calendar) and a guid (an event's ID). """ - host = self._service_root.split('//')[1].split(':')[0] - self.session.headers.update({'host': host}) params = dict(self.params) params.update({'lang': 'en-us', 'usertz': self.get_system_tz()}) url = '%s/%s/%s' % (self._calendar_event_detail_url, pguid, guid) @@ -78,8 +76,6 @@ class CalendarService(object): from_dt = datetime(today.year, today.month, first_day) if not to_dt: to_dt = datetime(today.year, today.month, last_day) - host = self._service_root.split('//')[1].split(':')[0] - self.session.headers.update({'host': host}) params = dict(self.params) params.update({ 'lang': 'en-us', diff --git a/pyicloud/services/contacts.py b/pyicloud/services/contacts.py index 27338d4..a5a79e0 100644 --- a/pyicloud/services/contacts.py +++ b/pyicloud/services/contacts.py @@ -22,8 +22,6 @@ class ContactsService(object): Refreshes the ContactsService endpoint, ensuring that the contacts data is up-to-date. """ - host = self._service_root.split('//')[1].split(':')[0] - self.session.headers.update({'host': host}) params_contacts = dict(self.params) params_contacts.update({ 'clientVersion': '2.1', diff --git a/pyicloud/services/findmyiphone.py b/pyicloud/services/findmyiphone.py index 1d9971c..7cce1bc 100644 --- a/pyicloud/services/findmyiphone.py +++ b/pyicloud/services/findmyiphone.py @@ -33,8 +33,6 @@ class FindMyiPhoneServiceManager(object): This ensures that the location data is up-to-date. """ - host = self._service_root.split('//')[1].split(':')[0] - self.session.headers.update({'host': host}) req = self.session.post( self._fmip_refresh_url, params=self.params, diff --git a/pyicloud/services/ubiquity.py b/pyicloud/services/ubiquity.py index 86878e2..30c7ec5 100644 --- a/pyicloud/services/ubiquity.py +++ b/pyicloud/services/ubiquity.py @@ -13,9 +13,6 @@ class UbiquityService(object): self._service_root = service_root self._node_url = '/ws/%s/%s/%s' - host = self._service_root.split('//')[1].split(':')[0] - self.session.headers.update({'host': host}) - def get_node_url(self, id, variant='item'): return self._service_root + self._node_url % ( self.params['dsid'],