Skip to content

Commit 5dbacb1

Browse files
committed
Add --text
1 parent 4257b74 commit 5dbacb1

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

build.sh

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@ cd src/cryptocli
1616
rm -rf cryptocli-*
1717
rm build.log || true
1818

19-
GOPATH=$(pwd)/.go
20-
GOPATH=${GOPATH} go get -v ./... || true
21-
GOPATH=${GOPATH} go get -u -v ./... || true
19+
go get -v ./...
2220

23-
(cd "$GOPATH/src/github.com/olivere/elastic/"; git fetch -t -f; git reset --hard origin/release-branch.v7)
24-
25-
GOPATH=${GOPATH} go build -o cryptocli-new .
21+
go build -o cryptocli-new .
2622
VERSION=$(git log @ -1 --format='%H %d')
2723

2824
compile() {
@@ -48,14 +44,14 @@ compile() {
4844
-- write-file --path "${DEST}.zip"
4945
}
5046

51-
compile darwin amd64
47+
#compile darwin amd64
5248
compile linux amd64
53-
compile linux 386
54-
compile linux arm64
55-
compile windows amd64
56-
compile windows 386
57-
compile openbsd amd64
58-
compile netbsd amd64
49+
#compile linux 386
50+
#compile linux arm64
51+
#compile windows amd64
52+
#compile windows 386
53+
#compile openbsd amd64
54+
#compile netbsd amd64
5955

6056
mv cryptocli-new cryptocli
6157

src/cryptocli/httpServer.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type HTTPServer struct {
2626
headers []string
2727
showClientHeaders bool
2828
showServerHeaders bool
29+
text bool
2930
}
3031

3132
var HTTPServerFormUploadPage = []byte(`
@@ -53,6 +54,7 @@ func (m *HTTPServer) SetFlagSet(fs *pflag.FlagSet, args []string) {
5354
fs.StringVar(&m.user, "user", "", "Specify the required user for basic auth")
5455
fs.StringVar(&m.password, "password", "", "Specify the required password for basic auth")
5556
fs.StringVar(&m.redirect, "redirect-to", "", "Redirect the request to where the download can begin")
57+
fs.BoolVar(&m.text, "text", false, "Set headers to show the content as text/plain rather than as an attachment")
5658
}
5759

5860
func HTTPServerHandleResponse(m *HTTPServer, w http.ResponseWriter, req *http.Request, relay *HTTPServerRelayer) {
@@ -107,8 +109,20 @@ func HTTPServerHandleResponse(m *HTTPServer, w http.ResponseWriter, req *http.Re
107109
return
108110
}
109111

110-
w.Header().Add("Content-Type", "application/octet-stream")
111-
w.Header().Add("Content-Disposition", "attachment;")
112+
if w.Header().Get("Content-Type") == "" {
113+
w.Header().Set("Content-Type", "application/octet-stream")
114+
}
115+
116+
if w.Header().Get("Content-Disposition") == "" {
117+
w.Header().Set("Content-Disposition", "attachment;")
118+
}
119+
120+
// Override headers if --text is set
121+
if m.text {
122+
w.Header().Set("Content-Type", "text/plain")
123+
w.Header().Set("Content-Disposition", "inline;")
124+
}
125+
112126
if m.showServerHeaders {
113127
ShowHTTPServerHeaders(w.Header())
114128
}

0 commit comments

Comments
 (0)