mirror of
https://opendev.org/x/pyghmi
synced 2025-01-14 19:57:47 +00:00
Handle 413 directly on the upload
413 may return on the upload, but sometimes not the status query. Support the direct evaluation of the return code. Change-Id: I4e8e8f4a03adc00d4c1de3a1fe4fbcb5d1b3d8f3
This commit is contained in:
parent
06159c4e1c
commit
eb7869bfa7
@ -1498,7 +1498,7 @@ class XCCClient(IMMClient):
|
||||
progress({'phase': 'upload',
|
||||
'progress': 100.0 * rsp['received'] / rsp['size']})
|
||||
elif rsp['state'] != 'done':
|
||||
if rsp.get('status', None) == 413:
|
||||
if rsp.get('status', None) == 413 or uploadthread.rspstatus == 413:
|
||||
raise Exception('File is larger than supported')
|
||||
raise Exception('Unexpected result:' + repr(rsp))
|
||||
uploadstate = rsp['state']
|
||||
|
@ -53,11 +53,17 @@ class FileUploader(threading.Thread):
|
||||
self.data = data
|
||||
self.otherfields = otherfields
|
||||
self.formname = formname
|
||||
self.rsp = ''
|
||||
self.rspstatus = 500
|
||||
super(FileUploader, self).__init__()
|
||||
|
||||
def run(self):
|
||||
self.rsp = self.wc.upload(self.url, self.filename, self.data,
|
||||
self.formname, otherfields=self.otherfields)
|
||||
try:
|
||||
self.rsp = self.wc.upload(self.url, self.filename, self.data,
|
||||
self.formname, otherfields=self.otherfields)
|
||||
except Exception:
|
||||
self.rspstatus = self.wc.rspstatus
|
||||
raise
|
||||
|
||||
|
||||
class FileDownloader(threading.Thread):
|
||||
@ -244,6 +250,7 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
del uploadforms[filename]
|
||||
except KeyError: # something could have already deleted it
|
||||
pass
|
||||
self.rspstatus = rsp.status
|
||||
if rsp.status != 200:
|
||||
raise Exception('Unexpected response in file upload: ' +
|
||||
rsp.read())
|
||||
|
Loading…
x
Reference in New Issue
Block a user