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


Python http.HTTPChannel类代码示例

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


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


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