r47311 - interfaces
hawkowl-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org Sat, 23 Apr 2016 22:14:08 -0600 (MDT)
| Newsgroups | gmane.comp.python.twisted.commits |
|---|---|
| Message-ID | <[email protected]> |
Author: hawkowl
Date: Sat Apr 23 22:14:03 2016
New Revision: 47311
Modified:
branches/proper-upgrade-8301-2/twisted/web/http.py
branches/proper-upgrade-8301-2/twisted/web/iweb.py
branches/proper-upgrade-8301-2/twisted/web/test/test_http.py
Log:
interfaces
Modified: branches/proper-upgrade-8301-2/twisted/web/http.py
==============================================================================
--- branches/proper-upgrade-8301-2/twisted/web/http.py (original)
+++ branches/proper-upgrade-8301-2/twisted/web/http.py Sat Apr 23 22:14:03 2016
@@ -2127,10 +2127,11 @@
if upgrader:
try:
- res = upgrader(self, path, headers)
+ res = upgrader(path, headers)
transport = self._channel.transport
self._channel, self._replay, headersToSend = res
- _respondToUpgrade(transport, upgrade, headersToSend)
+ if not self._replay:
+ _respondToUpgrade(transport, upgrade, headersToSend)
self._channel.makeConnection(transport)
return upgrade
except CannotUpgrade:
Modified: branches/proper-upgrade-8301-2/twisted/web/iweb.py
==============================================================================
--- branches/proper-upgrade-8301-2/twisted/web/iweb.py (original)
+++ branches/proper-upgrade-8301-2/twisted/web/iweb.py Sat Apr 23 22:14:03 2016
@@ -761,6 +761,22 @@
"""
+class IHTTPUpgradeable(Interface):
+ """
+ A factory which produces L{IProtocol} providers which will "take over" an
+ upgraded HTTP/1.1 request's transport.
+ """
+
+ def upgrade(self, path, headers):
+ """
+ Return a L{IProtocol} provider which will "take over" the transport.
+
+ @param path: The path of the incoming upgrade request.
+
+ @rtype: a 3-tuple of L{IProtocol} provider, whether to replay the original HTTP/1.1 request to the new protocol (in which case the returned L{IProtocol} provider will be responsible for the C{101 Switching Protocols} response), and extra headers to send with the C{101 Switching Protocols} response, if Twisted is responsible for sending it.
+ """
+
+
UNKNOWN_LENGTH = u"twisted.web.iweb.UNKNOWN_LENGTH"
Modified: branches/proper-upgrade-8301-2/twisted/web/test/test_http.py
==============================================================================
--- branches/proper-upgrade-8301-2/twisted/web/test/test_http.py (original)
+++ branches/proper-upgrade-8301-2/twisted/web/test/test_http.py Sat Apr 23 22:14:03 2016
@@ -2582,7 +2582,7 @@
piFactory = Factory()
piFactory.protocol = Pitocol
- def piNegotiate(channel, path, headers):
+ def piNegotiate(path, headers):
pi = piFactory.buildProtocol(None)
return pi, False, {b"beep": b"boop"}
@@ -2597,8 +2597,7 @@
val = [
b"GET / HTTP/1.1\r\n"
b"Connection: keep-alive, Upgrade\r\n",
- b"Upgrade: pitocol\r\n",
- b"beep: boop\r\n\r\n",
+ b"Upgrade: pitocol\r\n\r\n",
]
for x in iterbytes(b"".join(val)):
@@ -2606,7 +2605,8 @@
expectedValue = b"".join([
b"HTTP/1.1 101 Switching Protocols\r\nServer: ",
- _version, b"\r\nUpgrade: pitocol\r\nConnection: Upgrade\r\n\r\n"])
+ _version, b"\r\nUpgrade: pitocol\r\nConnection: Upgrade\r\n",
+ b"beep: boop\r\n\r\n"])
self.assertEqual(trans.value(), expectedValue)
trans.clear()