• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python http.HTTPChannel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.web.http.HTTPChannel的典型用法代码示例。如果您正苦于以下问题:Python HTTPChannel类的具体用法?Python HTTPChannel怎么用?Python HTTPChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: dataReceived

 def dataReceived(self, data):
     if self.protocol:
         # Pass the data off to the real protocol
         return self.protocol.dataReceived(data)
     
     # Try to determine the protocol requested
     if self.data:
         data = self.data + data
     self.data = data
     self.log.debug("Received %r", data)
     
     if len(data) >= 4:
         if "\0" in data:
             # Binary data; use DCSP
             self.switchProtocol(DaideServerProtocol())
             self.transport.setTcpKeepAlive(True)
         elif data.startswith("DPP/"):
             self.switchProtocol(DppProtocol())
             self.transport.setTcpKeepAlive(True)
         else:
             # Probably text; switch to HTTP
             proto = HTTPChannel()
             
             # Simulate Site.buildProtocol()
             site = self.factory.site
             proto.site = site
             proto.requestFactory = site.requestFactory
             proto.timeOut = site.timeOut
             
             self.switchProtocol(proto)
开发者ID:eswald,项目名称:parlance,代码行数:30,代码来源:network.py


示例2: YaybuChannel

class YaybuChannel(channel.SSHChannel):

    name = 'session'

    def __init__(self, task):
        channel.SSHChannel.__init__(self)
        self.protocol = HTTPChannel()
        self.protocol.requestFactory = self.request_factory
        self.protocol.transport = self
        self.disconnecting = False
        self.task = task

    def request_factory(self):
        return YaybuRequest(self.task)

    def openFailed(self, reason):
        print 'echo failed', reason

    def channelOpen(self, ignoredData):
        self.data = ''
        d = self.conn.sendRequest(self, 'exec', common.NS('yaybu --remote -'), wantReply = 1)
        #d.addCallback(self._cbRequest)

    def _cbRequest(self, ignored):
        #self.write('hello conch\n')
        #self.conn.sendEOF(self)
        pass

    def dataReceived(self, data):
        self.protocol.dataReceived(data)

    def closed(self):
        self.loseConnection()
        reactor.stop()
开发者ID:isotoma,项目名称:boiler,代码行数:34,代码来源:deploy.py


示例3: __init__

    def __init__(self, counter, method, path, headers, content):

        channel = HTTPChannel()
        host = IPv4Address(b"TCP", b"127.0.0.1", 80)
        channel.makeConnection(StringTransport(hostAddress=host))

        Request.__init__(self, channel, False)

        # An extra attribute for identifying this fake request
        self._counter = counter

        # Attributes a Request is supposed to have but we have to set ourselves
        # because the base class mixes together too much other logic with the
        # code that sets them.
        self.prepath = []
        self.requestHeaders = headers
        self.content = BytesIO(content)

        self.requestReceived(method, path, b"HTTP/1.1")

        # requestReceived initializes the path attribute for us (but not
        # postpath).
        self.postpath = list(map(unquote, self.path[1:].split(b'/')))

        # Our own notifyFinish / finish state because the inherited
        # implementation wants to write confusing stuff to the transport when
        # the request gets finished.
        self._finished = False
        self._finishedChannel = EventChannel()

        # Our own state for the response body so we don't have to dig it out of
        # the transport.
        self._responseBody = b""
开发者ID:alex-docker,项目名称:flocker,代码行数:33,代码来源:testtools.py


示例4: __init__

 def __init__(self, task):
     channel.SSHChannel.__init__(self)
     self.protocol = HTTPChannel()
     self.protocol.requestFactory = self.request_factory
     self.protocol.transport = self
     self.disconnecting = False
     self.task = task
开发者ID:isotoma,项目名称:boiler,代码行数:7,代码来源:deploy.py


示例5: test_client_sends_body

    def test_client_sends_body(self):
        self.cl.post_json("testserv:8008", "foo/bar", timeout=10000, data={"a": "b"})

        self.pump()

        clients = self.reactor.tcpClients
        self.assertEqual(len(clients), 1)
        client = clients[0][2].buildProtocol(None)
        server = HTTPChannel()

        client.makeConnection(FakeTransport(server, self.reactor))
        server.makeConnection(FakeTransport(client, self.reactor))

        self.pump(0.1)

        self.assertEqual(len(server.requests), 1)
        request = server.requests[0]
        content = request.content.read()
        self.assertEqual(content, b'{"a":"b"}')
开发者ID:matrix-org,项目名称:synapse,代码行数:19,代码来源:test_fedclient.py


示例6: dataReceived

    def dataReceived(self, data):
        if data.startswith("<policy-file-request/>"):

            policy = (
                '<?xml version="1.0"?><!DOCTYPE cross-domain-policy SYSTEM '
                '"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">'
                '<cross-domain-policy><allow-access-from domain="*" '
                'to-ports="*" /></cross-domain-policy>')
            self.transport.write(policy)
            self.transport.loseConnection()
        else:
            return HTTPChannel.dataReceived(self, data)
开发者ID:kowalski,项目名称:txWebSocket,代码行数:12,代码来源:websocket.py


示例7: __init__

 def __init__(self):
     HTTPChannel.__init__(self)
开发者ID:paoletto,项目名称:mediastreamer,代码行数:2,代码来源:twistedServeSingleFile.py


示例8: allHeadersReceived

 def allHeadersReceived(self):
     HTTPChannel.allHeadersReceived(self)
     req = self.requests[-1]
     if hasattr(req, "requestHeadersReceived"):
         req.requestHeadersReceived(self._command,
                                    self._path, self._version)
开发者ID:mensi,项目名称:gitserverglue,代码行数:6,代码来源:streamingweb.py


示例9: connectionLost

 def connectionLost(self, reason):
     self.site.lostClient()
     HTTPChannel.connectionLost(self, reason)
开发者ID:charmander,项目名称:weasyl,代码行数:3,代码来源:polecat.py


示例10: __init__

 def __init__(self):
     self.proxyConnection = None
     HTTPChannel.__init__(self)
开发者ID:nottombrown,项目名称:Convergence,代码行数:3,代码来源:ConnectChannel.py


示例11: connectionLost

 def connectionLost(self, reason):
     HTTPChannel.connectionLost(self, reason)
     self.site._lost_client()
开发者ID:david415,项目名称:carml,代码行数:3,代码来源:pastebin.py


示例12: __init__

	def __init__(self):

		self.ssl_context = tssl.DefaultOpenSSLContextFactory('data/cert/key.pem', 'data/cert/cert.pem')
		HTTPChannel.__init__(self)
开发者ID:digistump,项目名称:OakUpdateTool,代码行数:4,代码来源:oakupsrv.py


示例13: connectionLost

    def connectionLost(self, reason):
        logging.debug("Connection lost from client: " + str(reason))
        if (self.proxyConnection is not None):
            self.proxyConnection.transport.loseConnection()

        HTTPChannel.connectionLost(self, reason)
开发者ID:Boorena,项目名称:Convergence,代码行数:6,代码来源:ConnectChannel.py


示例14: __init__

 def __init__(self):
     HTTPChannel.__init__(self)
     self.content_type = None
     self.count_line_data = False
     self.co = self.dataCoroutine()
     self.co.next() # Start up the coroutine
开发者ID:ajdavis,项目名称:SyncSend,代码行数:6,代码来源:upload.py


示例15: connectionLost

 def connectionLost(self, reason):
     print "connectionLost in MyHTTPChannel. channel is ", self
     HTTPChannel.connectionLost(self,reason)
开发者ID:paoletto,项目名称:mediastreamer,代码行数:3,代码来源:twistedServeSingleFile.py


示例16: connectionMade

 def connectionMade(self):
     print "connectionMade in MyHTTPChannel"
     HTTPChannel.connectionMade(self)
开发者ID:paoletto,项目名称:mediastreamer,代码行数:3,代码来源:twistedServeSingleFile.py


示例17: connectionLost

	def connectionLost(self, reason):
		printStatus("Connection lost to: "+self.transport.getPeer().host)
		HTTPChannel.connectionLost(self, reason)
开发者ID:digistump,项目名称:OakUpdateTool,代码行数:3,代码来源:oakupsrv.py


示例18: connectionMade

 def connectionMade(self):
     HTTPChannel.connectionMade(self)
     self.site._got_client()
开发者ID:david415,项目名称:carml,代码行数:3,代码来源:pastebin.py


示例19: __init__

 def __init__(self, log):
     self.log, self.proxyConnection = log, None
     HTTPChannel.__init__(self)
开发者ID:mk-fg,项目名称:convergence,代码行数:3,代码来源:ConnectChannel.py


示例20: headerReceived

 def headerReceived(self, line):
    header = line.split(':')[0].lower()
    if header == "sec-websocket-key1" and not self._transferDecoder:
       HTTPChannel.headerReceived(self, "Content-Length: 8")
    HTTPChannel.headerReceived(self, line)
开发者ID:ctomc,项目名称:autobahntestsuite-maven-plugin,代码行数:5,代码来源:resource.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python http.HTTPClient类代码示例发布时间:2022-05-27
下一篇:
Python http.parse_qs函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap