File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,9 @@ module.exports = function wrapper(context) {
79
79
contentType += '; charset=UTF-8' ;
80
80
}
81
81
82
- res . setHeader ( 'Content-Type' , contentType ) ;
82
+ if ( ! res . getHeader ( 'Content-Type' ) ) {
83
+ res . setHeader ( 'Content-Type' , contentType ) ;
84
+ }
83
85
res . setHeader ( 'Content-Length' , content . length ) ;
84
86
85
87
const { headers } = context . options ;
Original file line number Diff line number Diff line change @@ -259,6 +259,27 @@ describe('Server', () => {
259
259
} ) ;
260
260
} ) ;
261
261
262
+ describe ( 'custom Content-Type' , ( ) => {
263
+ before ( ( done ) => {
264
+ app = express ( ) ;
265
+ const compiler = webpack ( webpackConfig ) ;
266
+ instance = middleware ( compiler , {
267
+ stats : 'errors-only' ,
268
+ logLevel,
269
+ headers : { 'Content-Type' : 'application/octet-stream' }
270
+ } ) ;
271
+ app . use ( instance ) ;
272
+ listen = listenShorthand ( done ) ;
273
+ } ) ;
274
+ after ( close ) ;
275
+
276
+ it ( 'Do not guess mime type if Content-Type header is found ' , ( done ) => {
277
+ request ( app ) . get ( '/bundle.js' )
278
+ . expect ( 'Content-Type' , 'application/octet-stream' )
279
+ . expect ( 200 , done ) ;
280
+ } ) ;
281
+ } ) ;
282
+
262
283
describe ( 'custom mimeTypes' , ( ) => {
263
284
before ( ( done ) => {
264
285
app = express ( ) ;
You can’t perform that action at this time.
0 commit comments