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.
This commit is contained in:
Tor Arne Vestbø 2016-01-07 22:13:08 +01:00
parent 35f7955228
commit 5d241fd1b5
5 changed files with 0 additions and 12 deletions

View file

@ -57,7 +57,6 @@ class PyiCloudService(object):
self.session = requests.Session() self.session = requests.Session()
self.session.verify = verify self.session.verify = verify
self.session.headers.update({ self.session.headers.update({
'Host': 'setup.icloud.com',
'Origin': self._home_endpoint, 'Origin': self._home_endpoint,
'Referer': '%s/' % self._home_endpoint, 'Referer': '%s/' % self._home_endpoint,
'User-Agent': 'Opera/9.52 (X11; Linux i686; U; en)' 'User-Agent': 'Opera/9.52 (X11; Linux i686; U; en)'

View file

@ -57,8 +57,6 @@ class CalendarService(object):
Fetches a single event's details by specifying a pguid Fetches a single event's details by specifying a pguid
(a calendar) and a guid (an event's ID). (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 = dict(self.params)
params.update({'lang': 'en-us', 'usertz': self.get_system_tz()}) params.update({'lang': 'en-us', 'usertz': self.get_system_tz()})
url = '%s/%s/%s' % (self._calendar_event_detail_url, pguid, guid) 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) from_dt = datetime(today.year, today.month, first_day)
if not to_dt: if not to_dt:
to_dt = datetime(today.year, today.month, last_day) 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 = dict(self.params)
params.update({ params.update({
'lang': 'en-us', 'lang': 'en-us',

View file

@ -22,8 +22,6 @@ class ContactsService(object):
Refreshes the ContactsService endpoint, ensuring that the Refreshes the ContactsService endpoint, ensuring that the
contacts data is up-to-date. 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 = dict(self.params)
params_contacts.update({ params_contacts.update({
'clientVersion': '2.1', 'clientVersion': '2.1',

View file

@ -33,8 +33,6 @@ class FindMyiPhoneServiceManager(object):
This ensures that the location data is up-to-date. 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( req = self.session.post(
self._fmip_refresh_url, self._fmip_refresh_url,
params=self.params, params=self.params,

View file

@ -13,9 +13,6 @@ class UbiquityService(object):
self._service_root = service_root self._service_root = service_root
self._node_url = '/ws/%s/%s/%s' 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'): def get_node_url(self, id, variant='item'):
return self._service_root + self._node_url % ( return self._service_root + self._node_url % (
self.params['dsid'], self.params['dsid'],