How to remove charset = utf-8 in the Content-Type header generated by spring-boot

I am trying to send mp4 file as response body in spring-boot. I tried setting the Content-Type header to video/mp4 using the following methods:

  • RequestMapping annotation parameter:

     @RequestMapping(value = "/movie.mp4", method = RequestMethod.GET, produces = "video/mp4") 
  • Manually adjusting the header value via HttpHeaders , passed to return a ResponseEntity .

Each time the resulting header looks like this:

 Content-Type:video/mp4; charset=UTF-8 

How to get rid of the postfix charset=UTF-8 ?

+7
spring spring-boot
source share
1 answer

It takes some debugging, but I found that HttpEncodingAutoConfiguration sets spring.http.encoding.force=true . If you set this parameter to false in application.properties , the encoding will be omitted.

+11
source share

All Articles