Use a LimitedStream so that unread request data will be ignored at the end of the request. WSGIRequest uses a LimitedStream but it shouldn't discard the data since the upstream servers usually do this. This fix applies only for testserver/runserver.
(self, stdin, stdout, stderr, environ, **kwargs)
| 116 | http_version = "1.1" |
| 117 | |
| 118 | def __init__(self, stdin, stdout, stderr, environ, **kwargs): |
| 119 | """ |
| 120 | Use a LimitedStream so that unread request data will be ignored at |
| 121 | the end of the request. WSGIRequest uses a LimitedStream but it |
| 122 | shouldn't discard the data since the upstream servers usually do this. |
| 123 | This fix applies only for testserver/runserver. |
| 124 | """ |
| 125 | try: |
| 126 | content_length = int(environ.get("CONTENT_LENGTH")) |
| 127 | except (ValueError, TypeError): |
| 128 | content_length = 0 |
| 129 | super().__init__( |
| 130 | LimitedStream(stdin, content_length), stdout, stderr, environ, **kwargs |
| 131 | ) |
| 132 | |
| 133 | def cleanup_headers(self): |
| 134 | super().cleanup_headers() |
nothing calls this directly
no test coverage detected