@polka/send-type
Advanced tools
Comparing version 0.4.0 to 0.5.0
15
index.js
const { STATUS_CODES } = require('http'); | ||
const TYPE = 'Content-Type'; | ||
const TYPE = 'content-type'; | ||
const OSTREAM = 'application/octet-stream'; | ||
module.exports = function (res, code=200, data='', headers={}) { | ||
let type = headers[TYPE]; | ||
let k, obj={}; | ||
for (k in headers) { | ||
obj[k.toLowerCase()] = headers[k]; | ||
} | ||
let type = obj[TYPE]; | ||
if (!!data && typeof data.pipe === 'function') { | ||
@@ -23,7 +28,7 @@ res.setHeader(TYPE, type || OSTREAM); | ||
headers[TYPE] = type || 'text/plain'; | ||
headers['Content-Length'] = Buffer.byteLength(data); | ||
obj[TYPE] = type || 'text/plain'; | ||
obj['content-length'] = Buffer.byteLength(data); | ||
res.writeHead(code, headers); | ||
res.writeHead(code, obj); | ||
res.end(data); | ||
} |
{ | ||
"name": "@polka/send-type", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "A response helper that detects & handles Content-Types", | ||
@@ -5,0 +5,0 @@ "repository": "lukeed/polka", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3520
26