From fabd84cb10beab2b2e5aed7489fc04df9fda7e83 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 4 Aug 2018 15:31:12 +0200 Subject: Properly handle failure to retrieve request body MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just truncate the WARC record like we do with responses. Also add a few tests, but they’re not covering the call to getRequestPostData. Not sure what we have to do here. --- crocoite/browser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crocoite/browser.py') diff --git a/crocoite/browser.py b/crocoite/browser.py index fbd12fd..c3ef5ce 100644 --- a/crocoite/browser.py +++ b/crocoite/browser.py @@ -103,7 +103,8 @@ class Item: return postData.encode ('utf8'), False elif req.get ('hasPostData', False): try: - return b64decode (self.tab.Network.getRequestPostData (requestId=self.id, _timeout=10)['postData']), True + postData = self.tab.Network.getRequestPostData (requestId=self.id, _timeout=10)['postData'] + return b64decode (postData), True except (pychrome.exceptions.CallMethodException, pychrome.exceptions.TimeoutException): raise ValueError ('Cannot fetch request body') return None, False @@ -315,6 +316,7 @@ class SiteLoader: level = {'verbose': Level.DEBUG, 'info': Level.INFO, 'warning': Level.WARNING, 'error': Level.ERROR}.get (entry.pop ('level'), Level.INFO) + entry['uuid'] = 'e62ffb5a-0521-459c-a3d9-1124551934d2' self.logger (level, 'console', **entry) def _javascriptDialogOpening (self, **kwargs): -- cgit v1.2.3