BaseHTTPRequestHandler.parse_request() loses client-provided information
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 36k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con BaseHTTPRequestHandler.parse_request() y compara su tratamiento actual de la solicitud //test con el comportamiento mostrado en el informe. Rastrea el cambio asociado a issue 87389 e identifica dónde se altera la ruta proporcionada por el cliente. Se considera terminado cuando las subclases, como el servidor de ejemplo, pueden recibir las barras iniciales originales sin hacer que la validación de solicitudes retroceda.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend-api-design, networking
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100