Skip to content

Commit

Permalink
remove mime types
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Oct 1, 2024
1 parent 9b8db29 commit 0882970
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var encodeUrl = require('encodeurl');
var escapeHtml = require('escape-html');
var http = require('http');
var onFinished = require('on-finished');
var mime = require('mime-types')
var path = require('path');
var pathIsAbsolute = require('path').isAbsolute;
var statuses = require('statuses')
Expand Down Expand Up @@ -495,11 +494,9 @@ res.download = function download (path, filename, options, callback) {

res.contentType =
res.type = function contentType(type) {
var ct = type.indexOf('/') === -1
? (mime.contentType(type) || 'application/octet-stream')
: type;
if(!type) type = "application/octet-stream"

return this.set('Content-Type', ct);
return this.set('Content-Type', type);
};

/**
Expand Down Expand Up @@ -666,7 +663,10 @@ res.header = function header(field, val) {
if (Array.isArray(value)) {
throw new TypeError('Content-Type cannot be set to an Array');
}
value = mime.contentType(value)

if ((value.startsWith('text/') || value === 'application/javascript' || value === 'application/json') && !charsetRegExp.test(value)) {
value += '; charset=utf-8';
}
}

this.setHeader(field, value);
Expand Down
1 change: 0 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
var Buffer = require('safe-buffer').Buffer
var contentType = require('content-type');
var etag = require('etag');
var mime = require('mime-types')
var proxyaddr = require('proxy-addr');
var qs = require('qs');
var querystring = require('querystring');
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"http-errors": "2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"mime-types": "^3.0.0",
"on-finished": "2.4.1",
"once": "1.4.0",
"parseurl": "~1.3.3",
Expand Down

0 comments on commit 0882970

Please sign in to comment.