本文整理汇总了Python中twisted.web.http.Request类的典型用法代码示例。如果您正苦于以下问题:Python Request类的具体用法?Python Request怎么用?Python Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connectionLost
def connectionLost(self, reason):
"""
Cleans up reply channel on close.
"""
if self.reply_channel:
del self.channel.factory.reply_protocols[self.reply_channel]
Request.connectionLost(self, reason)
示例2: __init__
def __init__(self, channel, queued, reactor=reactor):
Request.__init__(self, channel, queued)
self.reactor = reactor
self.urlMonitor = URLMonitor.getInstance()
self.cookieCleaner = CookieCleaner.getInstance()
self.dnsCache = DnsCache.getInstance()
self.plugins = ProxyPlugins.getInstance()
示例3: test_handle_request_method_raise_delugeerror
def test_handle_request_method_raise_delugeerror(self):
json = JSON()
def get_session_id(s_id):
return s_id
self.patch(deluge.ui.web.auth, 'get_session_id', get_session_id)
auth_conf = {'session_timeout': 10, 'sessions': {}}
auth = Auth(auth_conf)
request = Request(MagicMock(), False)
request.base = ''
auth._create_session(request)
methods = yield json.get_remote_methods()
# Verify the function has been registered
self.assertTrue('testclass.test' in methods)
request = MagicMock()
request.getCookie = MagicMock(return_value=list(auth.config['sessions'])[0])
json_data = {'method': 'testclass.test', 'id': 0, 'params': []}
request.json = json_lib.dumps(json_data)
request_id, result, error = json._handle_request(request)
result.addCallback(self.fail)
def on_error(error):
self.assertEqual(error.type, DelugeError)
result.addErrback(on_error)
yield result
示例4: __init__
def __init__(self, channel, queued, reactor = reactor):
Request.__init__(self, channel, queued)
logging.debug('Client request initiated...')
self.reactor = reactor
self.url_monitor = URLMonitor.get_instance()
self.cookie_cleaner = CookieCleaner.get_instance()
self.dns_cache = DNSCache.get_instance()
示例5: __init__
def __init__(self, channel, queued, reactor=reactor):
Request.__init__(self, channel, queued)
self.reactor = reactor
self.peers = {}
self.protocol = None
self.host = None
self.port = None
self.rest = None
self.configs = reactor.configs
self.log = Logger()
示例6: requestReceived
def requestReceived(self, command, path, version):
Request.requestReceived(self, command, path, version)
p = self.channel
source = self.channel.transport.getPeer()
destination = self.channel.transport.getHost()
client_id = (source.host, source.port)
p.nflogServer.logClient.logHTTP(client_id, destination.host,
destination.port, self.getRequestHostname(), path)
示例7: __init__
def __init__(self, channel, queued, reactor=reactor):
Request.__init__(self, channel, queued)
self.reactor = reactor
self.urlMonitor = URLMonitor.getInstance()
self.hsts = URLMonitor.getInstance().hsts
self.cookieCleaner = CookieCleaner.getInstance()
self.dnsCache = DnsCache.getInstance()
#self.uniqueId = random.randint(0, 10000)
#Use are own DNS server instead of reactor.resolve()
self.customResolver = dns.resolver.Resolver()
self.customResolver.nameservers = ['127.0.0.1']
示例8: serverResponse
def serverResponse(self, message):
"""
Writes a received HTTP response back out to the transport.
"""
# Write code
self.setResponseCode(message['status'])
# Write headers
for header, value in message.get("headers", {}):
self.setHeader(header.encode("utf8"), value.encode("utf8"))
# Write cookies
for cookie in message.get("cookies"):
self.cookies.append(cookie.encode("utf8"))
# Write out body
if "content" in message:
Request.write(self, message['content'].encode("utf8"))
self.finish()
示例9: __init__
def __init__(self, channel, path):
"""
@param channel: the channel we're connected to.
@param path: URI path
"""
Request.__init__(self, channel, queued=False)
# Unlike http.Request, which waits until it's received the whole request to set uri, args,
# and path, we must do this ASAP
self.uri = path
x = self.uri.split('?', 1)
if len(x) == 1:
self.path = self.uri
self.args = {}
else:
self.path, argstring = x
self.args = parse_qs(argstring, 1)
示例10: __init__
def __init__(self, channel, queued, reactor=reactor):
Request.__init__(self, channel, queued)
self.reactor = reactor
self.urlMonitor = URLMonitor.getInstance()
self.dnsCache = DnsCache.getInstance()
示例11: test_get_request_content_from_args
def test_get_request_content_from_args(self):
req = Request(None, True)
req.args = {'input': ['bar']}
self.assertEqual(self.transport.get_request_content(req), 'bar')
示例12: __init__
def __init__(self, *a, **kw):
self.yay = kw.pop('yay')
Request.__init__(self, *a, **kw)
示例13: __init__
def __init__(self, channel, queued, reactor=reactor):
Request.__init__(self, channel, queued)
self.reactor = reactor
self.PersistentData = PersistentData.getInstance()
示例14: __init__
def __init__(self, channel, queued=_QUEUED_SENTINEL, reactor=reactor):
Request.__init__(self, channel, queued)
self.reactor = reactor
示例15: __init__
def __init__(self, *args, **kwargs):
self.key = KEYFILE
self.cert = CERTFILE
self.opener = urllib2.build_opener(HTTPSClientCertHandler(self.key, self.cert))
Request.__init__(self, *args, **kwargs)