从POST请求返回视频

I have build a simple server for myself using Go and running into some odd issue.

I've created a route "/transcoding" where users can issue a POST HTTP request to with a multipart video file and receive back a modified video.

The problem I'm having is that when returning the video in the response, it doesn't seem to automatically play in Chrome/Safari/Firefox.

I know the video being returned is valid though because if I use curl/httpie or save set the content-type as attachment, the resulting file plays fine.

Is this something perhaps with POST-GET-REDIRECT ?

http -f POST http://localhost:8080/transcode input@~/Downloads/sample.mp4  

HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Disposition: attachment; filename=output.mp4
Content-Length: 398037
Content-Type: video/mp4
Date: Sun, 24 Jan 2016 22:00:00 GMT
Last-Modified: Sun, 24 Jan 2016 22:00:00 GMT



+-----------------------------------------+
| NOTE: binary data not shown in terminal |
+-----------------------------------------+

The above sample shows that I've set the Content-Length and Content-Type appropriately. The browser will show the video player however nothing plays. (If I drag-n-drop the saved file though, it will play)

"Content-Disposition: attachment" is not appropriate in this case. The MDN has a good description:

In a regular HTTP response, the Content-Disposition response header is a header indicating if the content is expected to be displayed inline in the browser, that is, as a Web page or as part of a Web page, or as an attachment, that is downloaded and saved locally.

If you want a browser to play the video, either remove the header or change the value to "inline".