File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 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) {
7979 contentType += '; charset=UTF-8' ;
8080 }
8181
82- res . setHeader ( 'Content-Type' , contentType ) ;
82+ if ( ! res . getHeader ( 'Content-Type' ) ) {
83+ res . setHeader ( 'Content-Type' , contentType ) ;
84+ }
8385 res . setHeader ( 'Content-Length' , content . length ) ;
8486
8587 const { headers } = context . options ;
Original file line number Diff line number Diff line change @@ -259,6 +259,27 @@ describe('Server', () => {
259259 } ) ;
260260 } ) ;
261261
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+
262283 describe ( 'custom mimeTypes' , ( ) => {
263284 before ( ( done ) => {
264285 app = express ( ) ;
You can’t perform that action at this time.
0 commit comments