Example #1
0
  def json_repr(self):
    """json_repr for HTTP response."""
    content =  {
      'size': len(self.body),
      'compression': len(self.body) - len(self.raw_body),
      'mimeType': self.mimeType
    }
    if self.encoding:
      content['encoding'] = self.encoding
      content['text'] = self.text
    elif self.text:
      content['text'] = self.text.encode('utf8') # must transcode to utf8

    headers = self.msg.headers
    return {
      'status': int(self.msg.status),
      'statusText': self.msg.reason,
      'httpVersion': self.msg.version,
      'cookies': [],
      'headersSize': -1,
      'bodySize': len(self.msg.body),
      'redirectURL': headers['location'] if 'location' in headers else '',
      'headers': http.header_json_repr(self.msg.headers),
      'content': content,
    }
Example #2
0
    def json_repr(self):
        """json_repr for HTTP response."""
        content = {
            "size": len(self.body),
            "compression": len(self.body) - len(self.raw_body),
            "mimeType": self.mimeType,
        }
        if self.encoding:
            content["encoding"] = self.encoding
            content["text"] = self.text
        elif self.text:
            content["text"] = self.text.encode("utf8")  # must transcode to utf8

        headers = self.msg.headers
        return {
            "status": int(self.msg.status),
            "statusText": self.msg.reason,
            "httpVersion": self.msg.version,
            "cookies": [],
            "headersSize": -1,
            "bodySize": len(self.msg.body),
            "redirectURL": headers["location"] if "location" in headers else "",
            "headers": http.header_json_repr(self.msg.headers),
            "content": content,
        }
Example #3
0
 def json_repr(self):
     """
 self = http.Request
 """
     return {
         "method": self.msg.method,
         "url": self.url,
         "httpVersion": self.msg.version,
         "cookies": [],
         "queryString": http.query_json_repr(self.query),
         "headersSize": -1,
         "headers": http.header_json_repr(self.msg.headers),
         "bodySize": len(self.msg.body),
     }
Example #4
0
 def json_repr(self):
   '''
   self = http.Request
   '''
   return {
     'method': self.msg.method,
     'url': self.url,
     'httpVersion': self.msg.version,
     'cookies': [],
     'queryString': http.query_json_repr(self.query),
     'headersSize': -1,
     'headers': http.header_json_repr(self.msg.headers),
     'bodySize': len(self.msg.body),
   }
Example #5
0
  def json_repr(self):
    '''
    self = http.Request
    '''
    postData = {}
    postData['text'] = self.msg.body
    try:
      postData['text'] = postData['text'].encode('utf8')
    except UnicodeDecodeError as e:
      postData['encoding'] = "base64"
      postData['text'] = base64.b64encode(self.msg.body)

    return {
      'method': self.msg.method,
      'url': self.url,
      'httpVersion': self.msg.version,
      'cookies': [],
      'queryString': http.query_json_repr(self.query),
      'headersSize': -1,
      'headers': http.header_json_repr(self.msg.headers),
      'bodySize': len(self.msg.body),
      'postData': postData,
    }
Example #6
0
    def json_repr(self):
        '''
    self = http.Request
    '''
        postData = {}
        postData['text'] = self.msg.body
        try:
            postData['text'] = postData['text'].encode('utf8')
        except UnicodeDecodeError as e:
            postData['encoding'] = "base64"
            postData['text'] = base64.b64encode(self.msg.body)

        return {
            'method': self.msg.method,
            'url': self.url,
            'httpVersion': self.msg.version,
            'cookies': [],
            'queryString': http.query_json_repr(self.query),
            'headersSize': -1,
            'headers': http.header_json_repr(self.msg.headers),
            'bodySize': len(self.msg.body),
            'postData': postData,
        }