mirror of
https://github.com/django/daphne.git
synced 2024-11-29 11:13:43 +03:00
Implement IProtocolNegotiationFactory.
This commit is contained in:
parent
0adf05246c
commit
9d708cda96
|
@ -5,7 +5,10 @@ import six
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
from zope.interface import implementer
|
||||||
|
|
||||||
from six.moves.urllib_parse import unquote, unquote_plus
|
from six.moves.urllib_parse import unquote, unquote_plus
|
||||||
|
from twisted.internet.interfaces import IProtocolNegotiationFactory
|
||||||
from twisted.protocols.policies import ProtocolWrapper
|
from twisted.protocols.policies import ProtocolWrapper
|
||||||
from twisted.web import http
|
from twisted.web import http
|
||||||
|
|
||||||
|
@ -275,6 +278,7 @@ class WebRequest(http.Request):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IProtocolNegotiationFactory)
|
||||||
class HTTPFactory(http.HTTPFactory):
|
class HTTPFactory(http.HTTPFactory):
|
||||||
"""
|
"""
|
||||||
Factory which takes care of tracking which protocol
|
Factory which takes care of tracking which protocol
|
||||||
|
@ -370,3 +374,18 @@ class HTTPFactory(http.HTTPFactory):
|
||||||
# Ping check
|
# Ping check
|
||||||
else:
|
else:
|
||||||
protocol.check_ping()
|
protocol.check_ping()
|
||||||
|
|
||||||
|
# IProtocolNegotiationFactory
|
||||||
|
def acceptableProtocols(self):
|
||||||
|
"""
|
||||||
|
Protocols this server can speak after ALPN negotiation. Currently that
|
||||||
|
is HTTP/1.1 and optionally HTTP/2. Websockets cannot be negotiated
|
||||||
|
using ALPN, so that doesn't go here: anyone wanting websockets will
|
||||||
|
negotiate HTTP/1.1 and then do the upgrade dance.
|
||||||
|
"""
|
||||||
|
baseProtocols = [b'http/1.1']
|
||||||
|
|
||||||
|
if http.H2_ENABLED:
|
||||||
|
baseProtocols.insert(0, b'h2')
|
||||||
|
|
||||||
|
return baseProtocols
|
||||||
|
|
Loading…
Reference in New Issue
Block a user