some sync fixes

- fix an extra \r\n being included at the end of the last form var
- req()s in the middle of a sync should throw an exception if they
receive a 403, as the calling code does not check for an empty return
This commit is contained in:
Damien Elmes 2016-12-21 10:42:13 +10:00
parent 7871949a6a
commit d181133ac0

View file

@ -552,7 +552,7 @@ class HttpSyncer(object):
# costly. We could send it as a raw post, but more HTTP clients seem to
# support file uploading, so this is the more compatible choice.
def req(self, method, fobj=None, comp=6, badAuthRaises=False):
def req(self, method, fobj=None, comp=6, badAuthRaises=True):
BOUNDARY=b"Anki-sync-boundary"
bdry = b"--"+BOUNDARY
buf = io.BytesIO()
@ -582,7 +582,8 @@ Content-Type: application/octet-stream\r\n\r\n""")
tgt.close()
break
tgt.write(data)
buf.write(b'\r\n' + bdry + b'--\r\n')
buf.write(b"\r\n")
buf.write(bdry + b'--\r\n')
size = buf.tell()
# connection headers
headers = {