[http.IncomingMessage] `req.toWeb()`
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.3k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 283
Descripción
What is the problem this feature will solve?
Reading the body out of the http.IncomingMessage is troublesome without any 3th party package...
Request on the other hand has features such as text, blob, json, arrayBuffer, formData bytes, and body for parsing it.
What is the feature you are proposing to solve the problem?
It would be a convenient to have something like a req.toWeb() utility added onto the simple http server 🚀
something like the stream.Readable.toWeb() but for the http.IncomingRequest to web Request
import http from 'node:http'
const app = http.createServer(async (req, res) => {
const request = req.toWeb()
await request.blob()
await request.arrayBuffer()
await request.bytes()
await request.formData()
await request.json()
await request.body.pipeTo(dest)
request.headers.has('content-length') // now getting the benefit of case insensitive.
// full url (populated with host from request headers and http(s) based on using http or https)
request.url
// a abort signal that aborts when user cancel the request
// can be useful for aborting other pending database queries
request.signal
})
What alternatives have you considered?
currently doing some simplier variant like this one:
const app = http.createServer((r, res) => {
const req = new Request(r.url, {
headers: r.headers,
method: r.method,
body: r
})
})
having this req.toWeb() built in would be very handy
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
Lee primero la ruta existente de http.createServer/IncomingMessage y la API stream.Readable.toWeb() mencionada en el issue. Define y verifica una conversión a un Request web que preserve los métodos de body propuestos, los headers, la URL y el comportamiento de la señal de abort; se considera terminado cuando la interfaz req.toWeb() solicitada funciona para estos casos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, node.js
- Área
- backend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 50/100