Content-Type and Content-Disposition HTTP headers

The Content-Type and Content-Disposition headers can be used to tell a browser to download a file instead of displaying it. Example Go code follows:

package main

import (

var interruptChannel = make(chan os.Signal, 1)

func content(w http.ResponseWriter, req *http.Request) {
	w.Header().Set("Content-Type", "text/csv; charset=UTF-8")
	w.Header().Set("Content-Disposition", "attachment")

func main() {
	http.HandleFunc("/content", content)
	server := http.Server{Addr: ":8080"}
	http.ListenAndServe(":8080", nil)
	go server.ListenAndServe()
	log.Println("Shutting down server")
	server.Shutdown(context.Background()) // blocks until all active connections become idle