Go http.FileServer streaming wrong file

Viewed 42

I use http.FileServer to provide image files downloading. Here's my code:

server := http.Server{
    Addr: "127.0.0.1:8080",
}
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
server.ListenAndServe()

I open the link: http://127.0.0.1:8080/static/, then right-click the link and choose "save as...".

The file size is correct, but the binary order of the file is wrong.

The left one is the original file, the right one is downloaded from the browser. Binary compare

When I use CURL, I cannot get the full-sized file. See the following testing CURL testing

Is there any magic related to 8MB?

1 Answers

There is no problem with Go code, Extra data saved in the original file is not the image, maybe your OS add some info to the image.

I tried the code in the Linux and both files were same as binary.

Related