Q:

Spring MVC: headers added in a RestController not returned

I have a simple Spring MVC RestController
@RestController
@RequestMapping(value = "/xxx")
public class MyResource {

One of the endpoint is meant to return a ZIP file so I have this:
@RequestMapping(value = "/xxx", method = RequestMethod.GET)
  public void downloadZip(HttpServletResponse response) {
        InputStream is = ...
        IOUtils.copy(is, response.getOutputStream());
        response.setContentType("application/zip");
        response.setHeader(HttpHeaders.CONTENT_DISPOSITION, attachment; filename=myfile.zip);
        response.flushBuffer();
  }

The above is meant to return a ZIP and add two extra header for the browser to know it's something that trigger a download.
But this is not the case, when I check the Response headers with chrome network tools, the header are exactly the same as before the request hit the endpoint.
The content-type is still application/json and the content-disposition is not even there.
I have custom header called "app-version". I did a test an try amending the value to see if it actually gets changed
response.setHeader("app-version","hello");

But no, when I check the Response header the "app-version" is still what was before the call.
Do I have to enable anything to be able to modify header inside my controller ?

A:

Try changing the return type from void to String 
public String downloadZip(HttpServletResponse response) {
        ...
        return ""        
  }

I think spring won't apply any change in header if the endpoint doesn't return anything.

