Issue with Content Type
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- ruby
- Área
- networking
Línea de trabajo
Reproduce la solicitud POST e inspecciona request.to_hash; después, lee net/http/header.rb alrededor de la línea 713, donde se produce el error reportado de Content-Type en minúsculas. Rastrea cómo interactúan header assignment y content_type; estará terminado cuando la asignación de encabezados sin distinción entre mayúsculas y minúsculas produzca un único Content-Type correcto sin requerir un segundo setter.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
We've identified an issue in the current release of net-http (0.3.2).
When setting a 'Content-Type' header on a POST request like so:
request['Content-Type'] = 'application/json'
It does set the header, however, it does not recognize that the Content-Type is set correctly and adds an additional header to the request with the default application/x-www-form-urlencoded
This can be seen when calling: request.to_hash.inspect:
{"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], "Accept"=>["*/*"], "User-Agent"=>["Ruby"], "Host"=>["api.songstats.com"], "Content-Type"=>["application/json"], "connection"=>["close"], "host"=>["api.songstats.com"], "content-length"=>["290"], "content-type"=>["application/x-www-form-urlencoded"]}
The only way to force the application/json header to go through is to explicitly set it in the request:
request.content_type = 'application/json'
So actually it needs to be set twice in order to fully work:
request['Content-Type'] = 'application/json'
request.content_type = 'application/json'
Also when setting request['content-type'] = 'application/json' in lower case it's throwing the error:
NoMethodError: undefined method `split' for nil:NilClass
from /Users/Oskar/.rbenv/versions/3.2.1/lib/ruby/3.2.0/net/http/header.rb:713:in `main_type'
It would be great if this can be streamlined so that setting the content-type in the headers immediately propagates across the entire request, without the need to set it multiple times or be cautious of case sensitivity. This took us a couple of hours to debug because we were un-aware that it currently sends the same header twice in the same request with different values.
- Lenguaje dominante
- Ruby
- Estrellas
- 148
- Forks
- 95
- Merge medio
- 10 h 54 min
- PR fusionados (30 d)
- 4
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
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 ruby/net-http
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
-
bug documentation
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
Todos los issues de ruby/net-http
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
バグ
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
-
Version bump for OpenVox 9 Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
voxpupuli/puppet-epel#186 · 1 comentario ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) AbiertoBug Frontend
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100