Aktueller Stand

This commit is contained in:
2026-01-22 19:05:45 +01:00
parent 85dee61a4d
commit e280e4eadb
1967 changed files with 397327 additions and 74093 deletions

View File

@@ -1,19 +1,27 @@
'use strict'
const http = require('http')
const http = require('node:http')
const send = require('..')
module.exports.shouldNotHaveHeader = function shouldNotHaveHeader (header, t) {
return function (res) {
t.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header)
t.assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header)
}
}
module.exports.shouldHaveHeader = function shouldHaveHeader (header, t) {
return function (res) {
t.assert.ok((header.toLowerCase() in res.headers), 'should have header ' + header)
}
}
module.exports.createServer = function createServer (opts, fn) {
return http.createServer(function onRequest (req, res) {
return http.createServer(async function onRequest (req, res) {
try {
fn && fn(req, res)
send(req, req.url, opts).pipe(res)
fn?.(req, res)
const { statusCode, headers, stream } = await send(req, req.url, opts)
res.writeHead(statusCode, headers)
stream.pipe(res)
} catch (err) {
res.statusCode = 500
res.end(String(err))
@@ -23,6 +31,6 @@ module.exports.createServer = function createServer (opts, fn) {
module.exports.shouldNotHaveBody = function shouldNotHaveBody (t) {
return function (res) {
t.ok(res.text === '' || res.text === undefined)
t.assert.ok(res.text === '' || res.text === undefined)
}
}