mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
sync: handle smartsync HTML responses better
If the server responds with an HTML page, we should show that to the user instead of crashing with XML errors. Bug: https://crbug.com/gerrit/15936 Change-Id: I52e6b781c3bb6a6c9f6ecbe2e0907044876cdc8d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/337519 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
48ea25c6a7
commit
5951e3043f
@ -28,6 +28,7 @@ import time
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
import xml.parsers.expat
|
||||
import xmlrpc.client
|
||||
|
||||
try:
|
||||
@ -1431,11 +1432,16 @@ class PersistentTransport(xmlrpc.client.Transport):
|
||||
raise
|
||||
|
||||
p, u = xmlrpc.client.getparser()
|
||||
while 1:
|
||||
data = response.read(1024)
|
||||
if not data:
|
||||
break
|
||||
# Response should be fairly small, so read it all at once.
|
||||
# This way we can show it to the user in case of error (e.g. HTML).
|
||||
data = response.read()
|
||||
try:
|
||||
p.feed(data)
|
||||
except xml.parsers.expat.ExpatError as e:
|
||||
raise IOError(
|
||||
f'Parsing the manifest failed: {e}\n'
|
||||
f'Please report this to your manifest server admin.\n'
|
||||
f'Here is the full response:\n{data.decode("utf-8")}')
|
||||
p.close()
|
||||
return u.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user