wsgiref validator complaining about no content-type when it is not needed
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 558
Mô tả
Bug report
https://github.com/python/cpython/blob/main/Lib/wsgiref/validate.py#L70 says that it wants to check
- That no Content-Type is given when there is no content
However, the code's behaviour appears not to match that.
The code notes there was uncertainty: https://github.com/python/cpython/blob/main/Lib/wsgiref/validate.py#L417
But more importantly, its behaviour is a contradiction with the stated objective mentioned above, as I interpret this.
I also cannot see where RFC2616 (which has been obsoleted by others, it would seem) mandates that behaviour.
In the following example, there is no content, and the validator complains about no Content-Type:
#!/usr/bin/env python3
from wsgiref.simple_server import make_server
from wsgiref.validate import validator
def wsgi_callable(environ, start_response):
start_response('302 Found', [('Location', 'https://example.com/')])
return [] # same result with None
make_server(host='localhost', port=8080, app=validator(wsgi_callable)).serve_forever()
When I make a request with curl localhost:8080, this error appears:
Traceback (most recent call last):
File "/usr/lib/python3.10/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib/python3.10/wsgiref/validate.py", line 181, in lint_app
iterator = application(environ, start_response_wrapper)
File "/home/calimero/test.py", line 7, in wsgi_callable
start_response('302 Found', [('Location', 'https://example.com/')])
File "/usr/lib/python3.10/wsgiref/validate.py", line 172, in start_response_wrapper
check_content_type(status, headers)
File "/usr/lib/python3.10/wsgiref/validate.py", line 428, in check_content_type
assert_(0, "No Content-Type header found in headers (%s)" % headers)
File "/usr/lib/python3.10/wsgiref/validate.py", line 128, in assert_
raise AssertionError(*args)
AssertionError: No Content-Type header found in headers ([('Location', 'https://example.com/')])
Your environment
- CPython version tested on: 3.10.4
- Operating system and architecture: Archlinux x86-64
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với Lib/wsgiref/validate.py, đặc biệt là phần mô tả gần dòng 70, điểm chưa chắc chắn được nêu gần dòng 417 và check_content_type quanh dòng 428. Tái hiện ví dụ redirect bằng validator và xem xét các yêu cầu WSGI hoặc HTTP liên quan. Công việc được xem là hoàn tất khi hành vi của validator phù hợp với mục tiêu đã nêu và có kiểm thử hồi quy cho trường hợp được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- backend
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100