uvicorn 0.30.4__py3-none-any.whl → 0.30.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uvicorn/__init__.py +1 -1
- uvicorn/protocols/http/h11_impl.py +18 -10
- uvicorn/protocols/http/httptools_impl.py +12 -10
- {uvicorn-0.30.4.dist-info → uvicorn-0.30.6.dist-info}/METADATA +1 -1
- {uvicorn-0.30.4.dist-info → uvicorn-0.30.6.dist-info}/RECORD +8 -8
- {uvicorn-0.30.4.dist-info → uvicorn-0.30.6.dist-info}/WHEEL +0 -0
- {uvicorn-0.30.4.dist-info → uvicorn-0.30.6.dist-info}/entry_points.txt +0 -0
- {uvicorn-0.30.4.dist-info → uvicorn-0.30.6.dist-info}/licenses/LICENSE.md +0 -0
uvicorn/__init__.py
CHANGED
@@ -147,14 +147,24 @@ class H11Protocol(asyncio.Protocol):
|
|
147
147
|
|
148
148
|
def _should_upgrade_to_ws(self) -> bool:
|
149
149
|
if self.ws_protocol_class is None:
|
150
|
-
if self.config.ws == "auto":
|
151
|
-
msg = "Unsupported upgrade request."
|
152
|
-
self.logger.warning(msg)
|
153
|
-
msg = "No supported WebSocket library detected. Please use \"pip install 'uvicorn[standard]'\", or install 'websockets' or 'wsproto' manually." # noqa: E501
|
154
|
-
self.logger.warning(msg)
|
155
150
|
return False
|
156
151
|
return True
|
157
152
|
|
153
|
+
def _unsupported_upgrade_warning(self) -> None:
|
154
|
+
msg = "Unsupported upgrade request."
|
155
|
+
self.logger.warning(msg)
|
156
|
+
if not self._should_upgrade_to_ws():
|
157
|
+
msg = "No supported WebSocket library detected. Please use \"pip install 'uvicorn[standard]'\", or install 'websockets' or 'wsproto' manually." # noqa: E501
|
158
|
+
self.logger.warning(msg)
|
159
|
+
|
160
|
+
def _should_upgrade(self) -> bool:
|
161
|
+
upgrade = self._get_upgrade()
|
162
|
+
if upgrade == b"websocket" and self._should_upgrade_to_ws():
|
163
|
+
return True
|
164
|
+
if upgrade is not None:
|
165
|
+
self._unsupported_upgrade_warning()
|
166
|
+
return False
|
167
|
+
|
158
168
|
def data_received(self, data: bytes) -> None:
|
159
169
|
self._unset_keepalive_if_required()
|
160
170
|
|
@@ -206,9 +216,7 @@ class H11Protocol(asyncio.Protocol):
|
|
206
216
|
"headers": self.headers,
|
207
217
|
"state": self.app_state.copy(),
|
208
218
|
}
|
209
|
-
|
210
|
-
upgrade = self._get_upgrade()
|
211
|
-
if upgrade == b"websocket" and self._should_upgrade_to_ws():
|
219
|
+
if self._should_upgrade():
|
212
220
|
self.handle_websocket_upgrade(event)
|
213
221
|
return
|
214
222
|
|
@@ -259,10 +267,10 @@ class H11Protocol(asyncio.Protocol):
|
|
259
267
|
self.transport.resume_reading()
|
260
268
|
self.conn.start_next_cycle()
|
261
269
|
continue
|
262
|
-
if self.conn.their_state == h11.MUST_CLOSE:
|
263
|
-
break
|
264
270
|
self.cycle.more_body = False
|
265
271
|
self.cycle.message_event.set()
|
272
|
+
if self.conn.their_state == h11.MUST_CLOSE:
|
273
|
+
break
|
266
274
|
|
267
275
|
def handle_websocket_upgrade(self, event: h11.Request) -> None:
|
268
276
|
if self.logger.level <= TRACE_LOG_LEVEL: # pragma: full coverage
|
@@ -141,19 +141,20 @@ class HttpToolsProtocol(asyncio.Protocol):
|
|
141
141
|
return upgrade
|
142
142
|
return None # pragma: full coverage
|
143
143
|
|
144
|
-
def _should_upgrade_to_ws(self
|
145
|
-
if
|
146
|
-
return
|
147
|
-
|
148
|
-
|
149
|
-
|
144
|
+
def _should_upgrade_to_ws(self) -> bool:
|
145
|
+
if self.ws_protocol_class is None:
|
146
|
+
return False
|
147
|
+
return True
|
148
|
+
|
149
|
+
def _unsupported_upgrade_warning(self) -> None:
|
150
|
+
self.logger.warning("Unsupported upgrade request.")
|
151
|
+
if not self._should_upgrade_to_ws():
|
150
152
|
msg = "No supported WebSocket library detected. Please use \"pip install 'uvicorn[standard]'\", or install 'websockets' or 'wsproto' manually." # noqa: E501
|
151
153
|
self.logger.warning(msg)
|
152
|
-
return False
|
153
154
|
|
154
155
|
def _should_upgrade(self) -> bool:
|
155
156
|
upgrade = self._get_upgrade()
|
156
|
-
return self._should_upgrade_to_ws(
|
157
|
+
return upgrade == b"websocket" and self._should_upgrade_to_ws()
|
157
158
|
|
158
159
|
def data_received(self, data: bytes) -> None:
|
159
160
|
self._unset_keepalive_if_required()
|
@@ -166,9 +167,10 @@ class HttpToolsProtocol(asyncio.Protocol):
|
|
166
167
|
self.send_400_response(msg)
|
167
168
|
return
|
168
169
|
except httptools.HttpParserUpgrade:
|
169
|
-
|
170
|
-
if self._should_upgrade_to_ws(upgrade):
|
170
|
+
if self._should_upgrade():
|
171
171
|
self.handle_websocket_upgrade()
|
172
|
+
else:
|
173
|
+
self._unsupported_upgrade_warning()
|
172
174
|
|
173
175
|
def handle_websocket_upgrade(self) -> None:
|
174
176
|
if self.logger.level <= TRACE_LOG_LEVEL:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
uvicorn/__init__.py,sha256=
|
1
|
+
uvicorn/__init__.py,sha256=o3l1sMdW81iZNyIR--S-G0OX1ua9vRy24ml-4PSD9H4,147
|
2
2
|
uvicorn/__main__.py,sha256=DQizy6nKP0ywhPpnCHgmRDYIMfcqZKVEzNIWQZjqtVQ,62
|
3
3
|
uvicorn/_subprocess.py,sha256=HbfRnsCkXyg7xCWVAWWzXQTeWlvLKfTlIF5wevFBkR4,2766
|
4
4
|
uvicorn/_types.py,sha256=TcUzCyKNq90ZX2Hxa6ce0juF558zLO_AyBB1XijnD2Y,7814
|
@@ -26,8 +26,8 @@ uvicorn/protocols/utils.py,sha256=rCjYLd4_uwPeZkbRXQ6beCfxyI_oYpvJCwz3jEGNOiE,18
|
|
26
26
|
uvicorn/protocols/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
27
|
uvicorn/protocols/http/auto.py,sha256=YfXGyzWTaaE2p_jkTPWrJCXsxEaQnC3NK0-G7Wgmnls,403
|
28
28
|
uvicorn/protocols/http/flow_control.py,sha256=050WVg31EvPOkHwynCoMP1zXFl_vO3U4durlc5vyp4U,1701
|
29
|
-
uvicorn/protocols/http/h11_impl.py,sha256=
|
30
|
-
uvicorn/protocols/http/httptools_impl.py,sha256=
|
29
|
+
uvicorn/protocols/http/h11_impl.py,sha256=MuX72-pIyZGHDtZ75-1mveeTj6_ruL-306Ug7z0yV8w,20765
|
30
|
+
uvicorn/protocols/http/httptools_impl.py,sha256=TikbbIZRFG08KTClZER47ehM1Tu8koBfT6WGU5t5ACg,21491
|
31
31
|
uvicorn/protocols/websockets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
32
32
|
uvicorn/protocols/websockets/auto.py,sha256=kNP-h07ZzjA9dKRUd7MNO0J7xhRJ5xVBfit7wCbdB0A,574
|
33
33
|
uvicorn/protocols/websockets/websockets_impl.py,sha256=59SLT1Q2sXnpbfxdk5e2SDTJPjrxOvqsYQOHxxCjCP4,15504
|
@@ -38,8 +38,8 @@ uvicorn/supervisors/multiprocess.py,sha256=Opt0XvOUj1DIMXYwb4OlkJZxeh_RjweFnTmDP
|
|
38
38
|
uvicorn/supervisors/statreload.py,sha256=gc-HUB44f811PvxD_ZIEQYenM7mWmhQQjYg7KKQ1c5o,1542
|
39
39
|
uvicorn/supervisors/watchfilesreload.py,sha256=41FGNMXPKrKvPr-5O8yRWg43l6OCBtapt39M-gpdk0E,3010
|
40
40
|
uvicorn/supervisors/watchgodreload.py,sha256=kd-gOvp14ArTNIc206Nt5CEjZZ4NP2UmMVYE7571yRQ,5486
|
41
|
-
uvicorn-0.30.
|
42
|
-
uvicorn-0.30.
|
43
|
-
uvicorn-0.30.
|
44
|
-
uvicorn-0.30.
|
45
|
-
uvicorn-0.30.
|
41
|
+
uvicorn-0.30.6.dist-info/METADATA,sha256=8mHWCwo1g631l-1XL1Km8_W6ik_qHHawLJfb792sKF4,6569
|
42
|
+
uvicorn-0.30.6.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
43
|
+
uvicorn-0.30.6.dist-info/entry_points.txt,sha256=FW1w-hkc9QgwaGoovMvm0ZY73w_NcycWdGAUfDsNGxw,46
|
44
|
+
uvicorn-0.30.6.dist-info/licenses/LICENSE.md,sha256=7-Gs8-YvuZwoiw7HPlp3O3Jo70Mg_nV-qZQhTktjw3E,1526
|
45
|
+
uvicorn-0.30.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|