MCPcopy
hub / github.com/benoitc/gunicorn / _get_alpn_protocols

Function _get_alpn_protocols

gunicorn/sock.py:238–264  ·  view source on GitHub ↗

Get ALPN protocol list from configuration. Returns list of ALPN protocol identifiers based on http_protocols setting. Returns empty list if HTTP/2 is not configured or available.

(conf)

Source from the content-addressed store, hash-verified

236
237
238def _get_alpn_protocols(conf):
239 """Get ALPN protocol list from configuration.
240
241 Returns list of ALPN protocol identifiers based on http_protocols setting.
242 Returns empty list if HTTP/2 is not configured or available.
243 """
244 from gunicorn.config import ALPN_PROTOCOL_MAP
245
246 http_protocols = conf.http_protocols
247 if not http_protocols:
248 return []
249
250 # Only configure ALPN if h2 is in the protocol list
251 if "h2" not in http_protocols:
252 return []
253
254 # Check if h2 library is available
255 from gunicorn.http2 import is_http2_available
256 if not is_http2_available():
257 return []
258
259 # Map to ALPN identifiers, maintaining preference order
260 alpn_protocols = []
261 for proto in http_protocols:
262 if proto in ALPN_PROTOCOL_MAP:
263 alpn_protocols.append(ALPN_PROTOCOL_MAP[proto])
264 return alpn_protocols
265
266
267def ssl_context(conf):

Callers 1

Calls 1

is_http2_availableFunction · 0.90

Tested by

no test coverage detected