当前位置: 首页>>代码示例>>Python>>正文


Python ProxyClient.handleEndHeaders方法代码示例

本文整理汇总了Python中twisted.web.proxy.ProxyClient.handleEndHeaders方法的典型用法代码示例。如果您正苦于以下问题:Python ProxyClient.handleEndHeaders方法的具体用法?Python ProxyClient.handleEndHeaders怎么用?Python ProxyClient.handleEndHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.web.proxy.ProxyClient的用法示例。


在下文中一共展示了ProxyClient.handleEndHeaders方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handleResponseEnd

# 需要导入模块: from twisted.web.proxy import ProxyClient [as 别名]
# 或者: from twisted.web.proxy.ProxyClient import handleEndHeaders [as 别名]
 def handleResponseEnd(self):
     if self.image_parser:
         print "imageparsing ", compress_rate
         try:
           image = self.image_parser.close()
         except IOError as (error):
           print "I/O error: ", error
           print self.image_parser
           
         
         try:
             # do the compression
             format = image.format
             newsize = int(image.size[0] * compress_rate) , int(image.size[1] * compress_rate)
             image.thumbnail(newsize) # likely, image sizing like this does not work
             s = StringIO()
             image.save(s, format)
             buffer = s.getvalue()
         except NameError as (error):
             print "in exception: ", error
             # send Original C-length if just queryed for header
             buffer = " " *(int(self.clength))
         print "Header:  Content-Lengths ", len(buffer)
         ProxyClient.handleHeader(self, "Content-Length", len(buffer))
         
         # all headers received and processed
         ProxyClient.handleEndHeaders(self)
         ProxyClient.handleResponsePart(self, buffer)
     
     ProxyClient.handleResponseEnd(self)
开发者ID:Eeko,项目名称:resizer_proxy,代码行数:32,代码来源:compressproxy.py

示例2: handleResponseEnd

# 需要导入模块: from twisted.web.proxy import ProxyClient [as 别名]
# 或者: from twisted.web.proxy.ProxyClient import handleEndHeaders [as 别名]
 def handleResponseEnd(self):
     log.msg("handleResponseEnd")
     if self.rewrite:
         banner2 = banner % dict(
             height = self.config['height'],
             bannerurl = self.config['bannerurl'],
             )
         buffer = self.buffer.replace("</head>", banner2)
         ProxyClient.handleHeader(self, "Content-Length", str(len(buffer)))
         ProxyClient.handleEndHeaders(self)
         ProxyClient.handleResponsePart(self, buffer)
         self.rewrite = False
     ProxyClient.handleResponseEnd(self)
开发者ID:isotoma,项目名称:badgerproxy,代码行数:15,代码来源:proxyclient.py

示例3: handleResponseEnd

# 需要导入模块: from twisted.web.proxy import ProxyClient [as 别名]
# 或者: from twisted.web.proxy.ProxyClient import handleEndHeaders [as 别名]
 def handleResponseEnd(self):
     if self.image_parser:
         image = self.image_parser.close()
         try:
             format = image.format
             image = image.rotate(180)
             s = StringIO()
             image.save(s, format)
             buffer = s.getvalue()
         except:
             buffer = ""
         ProxyClient.handleHeader(self, "Content-Length", len(buffer))
         ProxyClient.handleEndHeaders(self)
         ProxyClient.handleResponsePart(self, buffer)
     ProxyClient.handleResponseEnd(self)
开发者ID:tobiashochguertel,项目名称:postman-proxy_server.py,代码行数:17,代码来源:twisted-proxy.py

示例4: handleResponseEnd

# 需要导入模块: from twisted.web.proxy import ProxyClient [as 别名]
# 或者: from twisted.web.proxy.ProxyClient import handleEndHeaders [as 别名]
 def handleResponseEnd(self):
     if self.replacing is not None:
         try:
             buffer = open(self.replacing).read()
         except:
             buffer = ""
         ProxyClient.handleHeader(self, "Content-Length", len(buffer))
         ProxyClient.handleEndHeaders(self)
         ProxyClient.handleResponsePart(self, buffer)
     elif self.rewriting:
         buffer = self._buf.replace('"id": "BIRD_RED"', '"id": "BIRD_BLACK"')
         ProxyClient.handleHeader(self, "Content-Length", len(buffer))
         ProxyClient.handleEndHeaders(self)
         ProxyClient.handleResponsePart(self, buffer)
     ProxyClient.handleResponseEnd(self)
开发者ID:thouis,项目名称:works-in-progress,代码行数:17,代码来源:prox2.py

示例5: handleResponseEnd

# 需要导入模块: from twisted.web.proxy import ProxyClient [as 别名]
# 或者: from twisted.web.proxy.ProxyClient import handleEndHeaders [as 别名]
    def handleResponseEnd(self):
        if self.needsRewrite():
            log.msg("Rewriting " + self.father.uri)

            # We might have increased or decreased the page size. Since we have not written
            # to the client yet, we can still modify the headers.
            self.rewriteResponse()
            self.header_buffer["content-length"] = len(self.buffer)
            for key in self.header_buffer.keys():
                ProxyClient.handleHeader(self, key, self.header_buffer[key])
            ProxyClient.handleEndHeaders(self)
            ProxyClient.handleResponsePart(self, self.buffer) 
            
            self.buffer = ""
            self.header_buffer = {}
        
        ProxyClient.handleResponseEnd(self)
开发者ID:koto,项目名称:iplex_adblock,代码行数:19,代码来源:BufferingProxyClient.py

示例6: handleEndHeaders

# 需要导入模块: from twisted.web.proxy import ProxyClient [as 别名]
# 或者: from twisted.web.proxy.ProxyClient import handleEndHeaders [as 别名]
 def handleEndHeaders(self):
     ProxyClient.handleEndHeaders(self)
开发者ID:yknx4,项目名称:UnlockNeteaseMusicProxy,代码行数:4,代码来源:netease_music_proxy.py

示例7: handleEndHeaders

# 需要导入模块: from twisted.web.proxy import ProxyClient [as 别名]
# 或者: from twisted.web.proxy.ProxyClient import handleEndHeaders [as 别名]
 def handleEndHeaders(self):
     if not self.rewrite:
         if self.length:
             ProxyClient.handleHeader(self, "Content-Length", self.length)
         ProxyClient.handleEndHeaders(self)
开发者ID:isotoma,项目名称:badgerproxy,代码行数:7,代码来源:proxyclient.py

示例8: handleEndHeaders

# 需要导入模块: from twisted.web.proxy import ProxyClient [as 别名]
# 或者: from twisted.web.proxy.ProxyClient import handleEndHeaders [as 别名]
 def handleEndHeaders(self):
     if self.image_parser:
         pass #Need to calculate and send Content-Length first
     else:
         ProxyClient.handleEndHeaders(self)
开发者ID:tobiashochguertel,项目名称:postman-proxy_server.py,代码行数:7,代码来源:twisted-proxy.py

示例9: handleEndHeaders

# 需要导入模块: from twisted.web.proxy import ProxyClient [as 别名]
# 或者: from twisted.web.proxy.ProxyClient import handleEndHeaders [as 别名]
 def handleEndHeaders(self):
     if self.replacing or self.rewriting:
         pass  # Need to calculate and send Content-Length first
     else:
         ProxyClient.handleEndHeaders(self)
开发者ID:thouis,项目名称:works-in-progress,代码行数:7,代码来源:prox2.py

示例10: handleEndHeaders

# 需要导入模块: from twisted.web.proxy import ProxyClient [as 别名]
# 或者: from twisted.web.proxy.ProxyClient import handleEndHeaders [as 别名]
 def handleEndHeaders(self):
     if not self.needsRewrite():
         ProxyClient.handleEndHeaders(self)
开发者ID:koto,项目名称:iplex_adblock,代码行数:5,代码来源:BufferingProxyClient.py


注:本文中的twisted.web.proxy.ProxyClient.handleEndHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。