mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-14 12:15:53 +00:00
Fix #51
This commit is contained in:
parent
49224c703f
commit
d3cff80beb
4 changed files with 17 additions and 7 deletions
|
|
@ -58,8 +58,6 @@ def test_split_collection_timezones():
|
|||
given = [tuple(x) for x in split_collection(full)]
|
||||
expected = [(u'BEGIN:VCALENDAR',) + timezone + item + (u'END:VCALENDAR',)
|
||||
for item in items]
|
||||
print(given)
|
||||
print(expected)
|
||||
assert given == expected
|
||||
|
||||
|
||||
|
|
@ -72,7 +70,7 @@ def test_list(monkeypatch):
|
|||
u'DESCRIPTION:Beschreibung des Termines\n'
|
||||
u'END:VEVENT'),
|
||||
(u'BEGIN:VEVENT\n'
|
||||
u'SUMMARY:Eine zweite Kurzinfo\n'
|
||||
u'SUMMARY:Eine zweite Küèrzinfo\n'
|
||||
u'DESCRIPTION:Beschreibung des anderen Termines\n'
|
||||
u' With an extra line for description\n'
|
||||
u'BEGIN:VALARM\n'
|
||||
|
|
@ -96,7 +94,8 @@ def test_list(monkeypatch):
|
|||
r.status_code = 200
|
||||
assert responses
|
||||
r._content = responses.pop().encode('utf-8')
|
||||
r.encoding = 'utf-8'
|
||||
r.headers['Content-Type'] = 'text/icalendar'
|
||||
r.encoding = 'ISO-8859-1'
|
||||
return r
|
||||
|
||||
monkeypatch.setattr('requests.request', get)
|
||||
|
|
|
|||
|
|
@ -132,7 +132,8 @@ class HttpStorage(Storage):
|
|||
|
||||
self._settings = {
|
||||
'verify': prepare_verify(verify),
|
||||
'auth': prepare_auth(auth, username, password)
|
||||
'auth': prepare_auth(auth, username, password),
|
||||
'latin1_fallback': False
|
||||
}
|
||||
self.username, self.password = username, password
|
||||
self.useragent = useragent
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
import itertools
|
||||
|
||||
from . import exceptions, log
|
||||
from .utils import iteritems, itervalues
|
||||
from .utils import iteritems
|
||||
sync_logger = log.get(__name__)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ def get_password(username, resource):
|
|||
|
||||
|
||||
def request(method, url, data=None, headers=None, auth=None, verify=None,
|
||||
session=None):
|
||||
session=None, latin1_fallback=True):
|
||||
'''wrapper method for requests, to ease logging and mocking'''
|
||||
|
||||
if session is None:
|
||||
|
|
@ -200,7 +200,17 @@ def request(method, url, data=None, headers=None, auth=None, verify=None,
|
|||
logger.debug(data)
|
||||
logger.debug('Sending request...')
|
||||
r = func(method, url, data=data, headers=headers, auth=auth, verify=verify)
|
||||
|
||||
# See https://github.com/kennethreitz/requests/issues/2042
|
||||
content_type = r.headers.get('Content-Type', '')
|
||||
if not latin1_fallback and \
|
||||
'charset' not in content_type and \
|
||||
content_type.startswith('text/'):
|
||||
logger.debug('Removing latin1 fallback')
|
||||
r.encoding = None
|
||||
|
||||
logger.debug(r.status_code)
|
||||
logger.debug(r.headers)
|
||||
logger.debug(r.content)
|
||||
|
||||
return r
|
||||
|
|
|
|||
Loading…
Reference in a new issue