BaseHTTPRequestHandler.parse_request() loses client-provided information
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Bug report
The fix for https://github.com/python/cpython/issues/87389 prevents servers from handling request paths with multiple leading slashes.
For example, one might have a simple server that just reflects the request path:
from http.server import *
class MyHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write(self.path.encode('latin1'))
with ThreadingHTTPServer(('127.0.0.1', 8000), MyHTTPRequestHandler) as server:
server.serve_forever()
Previously, this would faithfully mirror the request path from the client:
$ curl -v http://localhost:8000//test
* Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET //test HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.82.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.6 Python/3.8.13
< Date: Mon, 07 Nov 2022 21:51:19 GMT
<
* Closing connection 0
//test
But now it mangles it:
$ curl -v http://localhost:8000//test
* Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET //test HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.82.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.6 Python/3.11.0
< Date: Mon, 07 Nov 2022 21:51:30 GMT
<
* Closing connection 0
/test
This impacts any servers that subclass BaseHTTPRequestHandler, such as eventlet's WSGI server.
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 BaseHTTPRequestHandler.parse_request() và so sánh cách xử lý hiện tại đối với yêu cầu //test với hành vi được thể hiện trong báo cáo. Truy vết thay đổi liên quan đến issue 87389 và xác định nơi đường dẫn do client cung cấp bị thay đổi. Được xem là hoàn tất khi các lớp con như example server có thể nhận các dấu gạch chéo ở đầu nguyên bản mà không làm hồi quy việc xác thực yêu cầu.
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-api-design, networking
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 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
- 45/100