Browse Source

Serve file directly for curl and wget user agents

Fix #127
pull/145/head
Thor77 6 years ago
parent
commit
85024eaeb2
  1. 8
      display.go

8
display.go

@ -4,6 +4,7 @@ import (
"encoding/json"
"net/http"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
@ -18,7 +19,14 @@ import (
const maxDisplayFileSizeBytes = 1024 * 512
var cliUserAgentRe = regexp.MustCompile("(?i)(lib)?curl|wget")
func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) {
if cliUserAgentRe.MatchString(r.Header.Get("User-Agent")) {
fileServeHandler(c, w, r)
return
}
fileName := c.URLParams["name"]
err := checkFile(fileName)

Loading…
Cancel
Save