Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

  1. A RequestMapping annotation parameter:

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

Each time the resulting header is as follows:

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

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

like image 956
P.Wiecek Avatar asked Sep 15 '15 12:09

P.Wiecek


1 Answers

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

like image 81
Ákos Ratku Avatar answered Oct 19 '22 23:10

Ákos Ratku