Permalink
Browse files

Expose raw bytes of HTTP message, including header.

  • Loading branch information...
1 parent 5ab670e commit 5261f217720aab524467d8933458e6c54393f12d Andrew Fleenor committed Aug 21, 2012
Showing with 14 additions and 1 deletion.
  1. +14 −1 pcap2har/http/message.py
@@ -9,7 +9,7 @@ class Message(object):
* seq_end: first sequence number past Message's data (slice-style indices)
* ts_start: when Message started arriving (dpkt timestamp)
* ts_end: when Message had fully arrived (dpkt timestamp)
- * body_raw: body before compression is taken into account
+ * raw_body: body before compression is taken into account
* tcpdir: The tcp.Direction corresponding to the HTTP message
'''
@@ -33,3 +33,16 @@ def __init__(self, tcpdir, pointer, msgclass):
self.ts_end = tcpdir.seq_final_arrival(self.seq_end - 1)
# get raw body
self.raw_body = self.msg.body
+ self.__pointer = pointer
+ # Access self.__raw_msg via raw_msg @property, which will set it if None
+ self.__raw_msg = None
+
+ @property
+ def raw_msg(self):
+ '''
+ Returns the message (including header) as a byte string.
+ '''
+ if not self.__raw_msg:
+ self.__raw_msg = self.tcpdir.data[
+ self.__pointer:(self.__pointer+self.data_consumed)]
+ return self.__raw_msg

0 comments on commit 5261f21

Please sign in to comment.