Fixup download handler

This commit is contained in:
Eliot Whalan 2016-06-24 12:05:14 +10:00
parent 65f6db2bf9
commit 631a536ce6
No known key found for this signature in database
GPG Key ID: C0A42175139840D6
1 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"bytes"
"crypto/sha1"
"database/sql"
"encoding/base64"
@ -13,6 +14,7 @@ import (
"io/ioutil"
"log"
"net/http"
"time"
"github.com/dchest/uniuri"
"github.com/ewhal/pygments"
@ -259,9 +261,7 @@ func downloadHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
paste := vars["pasteId"]
s := getPaste(paste, "")
w.Header().Set("Content-Disposition", "attachment; filename="+paste)
w.Header().Set("Content-Type", r.Header.Get("Content-Type"))
io.Copy(w, s)
http.ServeContent(w, r, paste, time.Now(), bytes.NewReader([]byte(s)))
}
func rawHandler(w http.ResponseWriter, r *http.Request) {