I've written a simple HTTP image server:
go/src/demo/demo.go:
package main
import (
"net/http"
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter()
router.HandleFunc("/foobar", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "/home/foobar/test.jpg")
})
http.ListenAndServe(":5000", router)
}
I compile it (PWD=$HOME/go/src/demo):
GOPATH=$PWD/../../ go build -o demo
And run:
./demo
Then in Chrome I open the URL. The image is corrupt -- reloading produces different corruption each time, once in a while it is fine. Larger images (~200KB) fail more often, smaller images (~20KB) fail less often.
Additional details:
go version
produces go version go1.9.5 linux/arm64
.
On my Macbook, this causes no issues -- only occurs on arm64 (looks like ResponseWriter does not implement flushing). I'm at a loss. Any ideas?