Add info to RequestEntityTooLarge exception.

Add 2 parameters to RequestEntityTooLarge exception:
blob_length - The size of the blob
limit - maximum number of bytes the reader should allow

Change-Id: I32bd4381f2b7b20f2fe642ffc71821872108471c
This commit is contained in:
Idan 2017-06-25 15:14:52 +00:00
parent 331a04defb
commit 25992053e4
1 changed files with 6 additions and 1 deletions

View File

@ -200,7 +200,12 @@ class LimitingReader(object):
self.sha1.update(res)
self.sha256.update(res)
if self.bytes_read > self.limit:
raise exception.RequestEntityTooLarge()
message = (_("The server is refusing to process a request because"
" the request entity with size of %(blob_length)s"
" bytes, is larger than the server is willing or able"
" to process - %(limit)s bytes.") %
{"blob_length": len_result, "limit": self.limit})
raise exception.RequestEntityTooLarge(message=message)
return res