Fixup download handler
This commit is contained in:
parent
98ded1615a
commit
0c8ff3ea04
6
main.go
6
main.go
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
@ -13,6 +14,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/dchest/uniuri"
|
"github.com/dchest/uniuri"
|
||||||
"github.com/ewhal/pygments"
|
"github.com/ewhal/pygments"
|
||||||
|
@ -259,9 +261,7 @@ func downloadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
paste := vars["pasteId"]
|
paste := vars["pasteId"]
|
||||||
s := getPaste(paste, "")
|
s := getPaste(paste, "")
|
||||||
w.Header().Set("Content-Disposition", "attachment; filename="+paste)
|
http.ServeContent(w, r, paste, time.Now(), bytes.NewReader([]byte(s)))
|
||||||
w.Header().Set("Content-Type", r.Header.Get("Content-Type"))
|
|
||||||
io.Copy(w, s)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
func rawHandler(w http.ResponseWriter, r *http.Request) {
|
func rawHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
Loading…
Reference in New Issue