From bcfbdd9b45b7e872ee77e1366197443d855d8c7c Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 22 Dec 2017 17:04:39 +0100 Subject: SiteLoader: Save entire finished response --- crocoite/browser.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crocoite/browser.py b/crocoite/browser.py index 3e0e310..e7eb4e2 100644 --- a/crocoite/browser.py +++ b/crocoite/browser.py @@ -33,7 +33,7 @@ class Item: def __init__ (self): self.chromeRequest = None self.chromeResponse = None - self.encodedDataLength = 0 + self.chromeFinished = None def __repr__ (self): return ''.format (self.request['url']) @@ -54,12 +54,19 @@ class Item: def id (self): return self.chromeRequest['requestId'] + @property + def encodedDataLength (self): + return self.chromeFinished['encodedDataLength'] + def setRequest (self, req): self.chromeRequest = req def setResponse (self, resp): self.chromeResponse = resp + def setFinished (self, finished): + self.chromeFinished = finished + class SiteLoader: """ Load site in Chrome and monitor network requests @@ -199,7 +206,7 @@ class SiteLoader: url = urlsplit (resp['url']) if url.scheme in self.allowedSchemes: self.logger.info ('finished {} {}'.format (reqId, req['url'])) - item.encodedDataLength = kwargs['encodedDataLength'] + item.setFinished (kwargs) self.loadingFinished (item) def _loadingFailed (self, **kwargs): -- cgit v1.2.3