Example #1
0
    def __init__(self, options, is_request, params):
        BaseProcessor.__init__(self, options, is_request, params)

        param_dict = {
            BUFFER_SIZE: 32768,
            DEFLATE_SIZE: None,
            DELTA_USAGE: True,
            DELTA_TYPE: (DELTA_FULL, ""),
            HUFFMAN: False,
        }
        for param in params:
            if "=" in param:
                name, value = param.split("=", 1)
            else:
                name = param
                value = None
            if name in param_functions:
                param_dict[name] = param_functions[name](value)
            else:
                param_dict[name] = value

        self.codec = HeaderDiffCodec(
            param_dict[BUFFER_SIZE],
            windowSize=param_dict[DEFLATE_SIZE],
            dict=spdy_dictionary.spdy_dict,
            delta_usage=param_dict[DELTA_USAGE],
            delta_type=param_dict[DELTA_TYPE],
            huffman=param_dict[HUFFMAN],
            isRequest=is_request,
        )
Example #2
0
class Processor(BaseProcessor):
    def __init__(self, options, is_request, params):
        BaseProcessor.__init__(self, options, is_request, params)

        param_dict = {
            BUFFER_SIZE: 32768,
            DEFLATE_SIZE: None,
            DELTA_USAGE: True,
            DELTA_TYPE: (DELTA_FULL, ""),
            HUFFMAN: False,
        }
        for param in params:
            if "=" in param:
                name, value = param.split("=", 1)
            else:
                name = param
                value = None
            if name in param_functions:
                param_dict[name] = param_functions[name](value)
            else:
                param_dict[name] = value

        self.codec = HeaderDiffCodec(
            param_dict[BUFFER_SIZE],
            windowSize=param_dict[DEFLATE_SIZE],
            dict=spdy_dictionary.spdy_dict,
            delta_usage=param_dict[DELTA_USAGE],
            delta_type=param_dict[DELTA_TYPE],
            huffman=param_dict[HUFFMAN],
            isRequest=is_request,
        )

    def compress(self, in_headers, host):
        hdrs = dict(in_headers)
        hdrs = HeaderTuple.split_from_dict(hdrs)

        frame = self.codec.encodeHeaders(hdrs, self.is_request)
        return frame

    def decompress(self, compressed):
        headers = self.codec.decodeHeaders(compressed, self.is_request)
        hdrs = {}
        for k, v in headers:
            if k in hdrs:
                if k == "cookie":
                    hdrs[k] += ";" + v
                else:
                    hdrs[k] += "\0" + v
            else:
                hdrs[k] = v

        return hdrs
Example #3
0
class Processor(BaseProcessor):
  def __init__(self, options, is_request, params):
    BaseProcessor.__init__(self, options, is_request, params)
    
    param_dict = {
      BUFFER_SIZE: 32768,
      DEFLATE_SIZE: None,
      DELTA_USAGE: True,
      DELTA_TYPE: (DELTA_FULL, ""),
      HUFFMAN: False,
    }
    for param in params:
      if "=" in param:
        name, value = param.split("=", 1)
      else:
        name = param
        value = None
      if name in param_functions:
        param_dict[name] = param_functions[name](value)
      else:
        param_dict[name] = value
    
    self.codec = HeaderDiffCodec(
      param_dict[BUFFER_SIZE],
      windowSize=param_dict[DEFLATE_SIZE],
      dict=spdy_dictionary.spdy_dict,
      delta_usage=param_dict[DELTA_USAGE],
      delta_type=param_dict[DELTA_TYPE],
      huffman=param_dict[HUFFMAN],
      isRequest=is_request,
      )
  
  def compress(self, in_headers, host):
    hdrs = dict(in_headers)
    hdrs = HeaderTuple.split_from_dict(hdrs)
    
    frame = self.codec.encodeHeaders(hdrs, self.is_request)
    return frame
  
  def decompress(self, compressed):
    headers = self.codec.decodeHeaders(compressed, self.is_request)
    hdrs = {}
    for k, v in headers:
      if k in hdrs:
        if k == "cookie":
          hdrs[k] += ";" + v
        else:
          hdrs[k] += "\0" + v
      else:
        hdrs[k] = v
    
    return hdrs
Example #4
0
 def __init__(self, options, is_request, params):
   BaseProcessor.__init__(self, options, is_request, params)
   
   param_dict = {
     BUFFER_SIZE: 32768,
     DEFLATE_SIZE: None,
     DELTA_USAGE: True,
     DELTA_TYPE: (DELTA_FULL, ""),
     HUFFMAN: False,
   }
   for param in params:
     if "=" in param:
       name, value = param.split("=", 1)
     else:
       name = param
       value = None
     if name in param_functions:
       param_dict[name] = param_functions[name](value)
     else:
       param_dict[name] = value
   
   self.codec = HeaderDiffCodec(
     param_dict[BUFFER_SIZE],
     windowSize=param_dict[DEFLATE_SIZE],
     dict=spdy_dictionary.spdy_dict,
     delta_usage=param_dict[DELTA_USAGE],
     delta_type=param_dict[DELTA_TYPE],
     huffman=param_dict[HUFFMAN],
     isRequest=is_request,
     )