當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。