本文整理汇总了Python中twisted.web.http.HTTPClient类的典型用法代码示例。如果您正苦于以下问题:Python HTTPClient类的具体用法?Python HTTPClient怎么用?Python HTTPClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTTPClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleResponseEnd
def handleResponseEnd(self):
if (self.isImageRequest):
self.shutdown()
else:
try:
HTTPClient.handleResponseEnd(self)
except:
pass
示例2: handleResponseEnd
def handleResponseEnd(self):
if (self.isImageRequest):
self.shutdown()
else:
try:
HTTPClient.handleResponseEnd(self) #Gets rid of some generic errors
except:
pass
示例3: __init__
def __init__(self):
try:
TwistedHTTPClient.__init__(self)
except AttributeError:
pass
self.code = None
self.headers = ordereddict.OrderedDict()
self.connect_df = Deferred()
self.response_df = Deferred()
示例4: __init__
def __init__(self):
try:
TwistedHTTPClient.__init__(self)
except AttributeError:
pass
self.code = None
self.headers = OrderedDict()
self.connect_cb = Callback()
self.response_cb = Callback()
示例5: lineReceived
def lineReceived(self, line):
try:
HTTPClient.lineReceived(self, line.rstrip())
except:
self.factory.invalid_headers.append(line)
if hasattr(self.transport, 'abortConnection'):
self.transport.abortConnection()
else:
self.transport.loseConnection()
示例6: handleResponsePart
def handleResponsePart(self, data):
HTTPClient.handleResponsePart(self, data)
self.body_size += len(data)
if (self.factory.download_size and
self.body_size > self.factory.download_size):
self.transport.loseConnection()
self.factory.noPage(
DownloadSizeError('Response exceeded %s bytes.' %
self.factory.download_size))
示例7: lineReceived
def lineReceived(self, line):
if self.factory.use_tunnel and not self.tunnel_started: log.msg("LINE: %s" % line)
if self.factory.use_tunnel and not self.tunnel_started and not line.rstrip():
# End of headers from the proxy in response to our CONNECT request
# Skip the call to HTTPClient.lienReceived for now, since otherwise
# it would switch to row mode.
self.startTunnel()
else:
return HTTPClient.lineReceived(self, line.rstrip())
示例8: lineReceived
def lineReceived(self, line):
return HTTPClient.lineReceived(self, line.rstrip())
示例9: connectionLost
def connectionLost(self, reason):
self._connection_lost_reason = reason
HTTPClient.connectionLost(self, reason)
self.factory.noPage(reason)
示例10: handleResponseEnd
def handleResponseEnd(self):
if self.actAs == self.PersistentData._PROXY:
self.shutdown()
else:
HTTPClient.handleResponseEnd(self)
示例11: connectionMade
def connectionMade(self):
HTTPClient.connectionMade(self)
self.data = None
self.make_request()
self.headers = defaultdict(list)
示例12: handleResponseEnd
def handleResponseEnd(self):
if self.isImageRequest:
self.shutdown()
else:
HTTPClient.handleResponseEnd(self)
示例13: handleResponseEnd
def handleResponseEnd(self):
try:
HTTPClient.handleResponseEnd(self)
except:
pass
示例14: handleResponsePart
def handleResponsePart(self, data):
HTTPClient.handleResponsePart(self, data)
示例15: lineReceived
def lineReceived(self, line):
try:
HTTPClient.lineReceived(self, line.rstrip())
except:
self.factory.add_invalid_header(line)