[http.IncomingMessage] `req.toWeb()`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Lies zuerst den bestehenden Pfad von http.createServer/IncomingMessage und die in der Issue genannte API stream.Readable.toWeb(). Definiere und überprüfe eine Konvertierung in einen Web-Request, die das vorgeschlagene Verhalten der Body-Methoden, Header, URL und des Abort-Signals beibehält; abgeschlossen ist die Aufgabe, wenn die angeforderte req.toWeb()-Schnittstelle für diese Fälle funktioniert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js
- Bereich
- backend
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 50/100