Permalink
Browse files

Fix the memory error fix

Drop tcpdir.data AFTER all http messages have been constructed
from it.
  • Loading branch information...
1 parent 5261f21 commit 51e7a9c50a18e61fccffe33b154e699726545a08 Andrew Fleenor committed Aug 21, 2012
Showing with 1,132 additions and 7 deletions.
  1. +5 −0 pcap2har/http/flow.py
  2. +2 −4 pcap2har/http/response.py
  3. +1,102 −0 tests/fhs.pcap.dropped.har
  4. +23 −3 tests/run_tests.sh
View
@@ -4,6 +4,7 @@
import common as http
from request import Request
from response import Response
+from .. import settings
class Flow(object):
@@ -30,6 +31,10 @@ def __init__(self, tcpflow):
if not success:
# flow is not HTTP
raise HTTPError('TCP Flow does not contain HTTP')
+ # now optionally clear the data on tcpflow
+ if settings.drop_bodies:
+ tcpflow.fwd.clear_data()
+ tcpflow.rev.clear_data()
# match up requests with nearest response that occured after them
# first request is the benchmark; responses before that
# are irrelevant for now
@@ -66,13 +66,11 @@ def clear_body(self):
'''
Clear response body to save memory
- Sets to None the body attributes of self and self.msg, and
- maybe tcpdir, too. Of course, they can't be GC'd if there
- are any other references.
+ http.Flow has to do most of the work (after any other responses are
+ parsed), here we just want to get rid of any references.
'''
self.body = self.raw_body = None
self.msg.body = None
- self.tcpdir.clear_data() # clear stream data, not timing, etc
def handle_compression(self):
'''
Oops, something went wrong.

0 comments on commit 51e7a9c

Please sign in to comment.