HttpClient removes Content-Length and causes 411
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- swift
- Área
- networking
Línea de trabajo
Comienza en RequestValidation.swift, en setTransportFraming, donde se elimina Content-Length para las solicitudes GET de longitud cero. Sigue cómo se configuran los encabezados de la solicitud y determina dónde podría exponerse una sobrescritura. La tarea estará terminada cuando los llamadores puedan forzar un Content-Length apropiado para las solicitudes GET y la solicitud resultante funcione con servidores que devuelven 411 cuando no está presente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
When attempting to make GET calls with Django based server, I'm getting a 411 Length Required. Looking at the code in RequestValidation.swift, it is removing Content-Length from headers for GET calls. This may be according to specs but it appears that some servers still require this (probably set to 0). There should be some way to override this behavior or to cause it to force Content-Length to appear in the headers.
I have worked around this by implementing my own networking code using URLSession and the calls do work since I can control the headers exactly.
For reference, the code that is causing the problem is here:
private mutating func setTransportFraming(
method: HTTPMethod,
bodyLength: RequestBodyLength
) {
self.remove(name: "Content-Length")
self.remove(name: "Transfer-Encoding")
switch bodyLength {
case .known(0):
// if we don't have a body we might not need to send the Content-Length field
// https://tools.ietf.org/html/rfc7230#section-3.3.2
switch method {
case .GET, .HEAD, .DELETE, .CONNECT, .TRACE:
// A user agent SHOULD NOT send a Content-Length header field when the request
// message does not contain a payload body and the method semantics do not
// anticipate such a body.
break
default:
// A user agent SHOULD send a Content-Length in a request message when
// no Transfer-Encoding is sent and the request method defines a meaning
// for an enclosed payload body.
self.add(name: "Content-Length", value: "0")
}
case .known(let length):
self.add(name: "Content-Length", value: String(length))
case .unknown:
self.add(name: "Transfer-Encoding", value: "chunked")
}
}
- Lenguaje dominante
- Swift
- Estrellas
- 1.1k
- Forks
- 156
- Merge medio
- 1 h 54 min
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la 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.
Más de swift-server/async-http-client
-
RequestBag keeps the request body after an early response with status >= 300Posiblemente ocupada @beshkenadze la tomó hace 1 día. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
swift-server/async-http-client#941 ·
Los mantenedores suelen responder en 1 día
-
HTTP/2 stream stays half-closed after an early response with status >= 300Posiblemente ocupada @beshkenadze la tomó hace 1 día. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
swift-server/async-http-client#940 ·
Los mantenedores suelen responder en 1 día
-
Transaction keeps the request body after an early response with status >= 300Posiblemente ocupada @beshkenadze la tomó hace 1 día. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
swift-server/async-http-client#939 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
swift-server/async-http-client#938 ·
Los mantenedores suelen responder en 1 día
-
Invalid state: idleAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
swift-server/async-http-client#927 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de swift-server/async-http-client
Issues similares
-
ci-failure ci:assertion test
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
openwatersio/slackwater-ios#811 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
foxglove/mcap#1907 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
good first issue help wanted translation
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
-
[Tool] AnnotatorAbiertohas-image has-license has-readme new-tool ready-to-approve repo-verified
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
shanselman/TinyToolTown#873 ·
Los mantenedores suelen responder en 5 días