Skip to content

Commit ec79d64

Browse files
author
Chris Lenz
committed
Updated README.md
1 parent e4f0775 commit ec79d64

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ go clean -i github.com/idefixcert/httpsink
1717
## Download the prebuild files from github
1818

1919
```
20-
wget https://github.com/idefixcert/httpsink/releases/download/v1.0.0/httpsink_v1.0.0_linux_386.tar.gz
21-
tar -xzvf httpsink_v1.0.0_linux_386.tar.gz
20+
wget https://github.com/idefixcert/httpsink/releases/download/1.1.2/httpsink_1.1.2_linux_386.tar.gz
21+
tar -xzvf httpsink_v1.1.2_linux_386.tar.gz
2222
```

httpsink.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ func rootHandler(sleep time.Duration) http.HandlerFunc {
4141

4242
func proxyHandler(target string) http.HandlerFunc {
4343
return func(w http.ResponseWriter, req *http.Request) {
44-
// parse the url
45-
url, _ := url.Parse(target)
44+
// parse the targetURL
45+
targetURL, _ := url.Parse(target)
4646

4747
// create the reverse proxy
48-
proxy := httputil.NewSingleHostReverseProxy(url)
48+
proxy := httputil.NewSingleHostReverseProxy(targetURL)
4949

5050
// Update the headers to allow for SSL redirection
51-
req.URL.Host = url.Host
52-
req.URL.Scheme = url.Scheme
51+
req.URL.Host = targetURL.Host
52+
req.URL.Scheme = targetURL.Scheme
5353
req.Header.Set("X-Forwarded-Host", req.Header.Get("Host"))
54-
req.Host = url.Host
54+
req.Host = targetURL.Host
5555

5656
// Note that ServeHttp is non blocking and uses a go routine under the hood
5757
proxy.ServeHTTP(w, req)
@@ -75,7 +75,7 @@ func logRequest(handler http.Handler) http.Handler {
7575
message := fmt.Sprintf("Request:\n%s\nResponse Code: %d\nResponse:\n%s\n\n", string(x), rec.Code, rec.Body.String())
7676
if rec.Code >= 500 {
7777
color.Error.Block(message)
78-
} else if rec.Code >= 404 {
78+
} else if rec.Code >= 400 {
7979
color.Warn.Block(message)
8080
} else if rec.Code >= 200 {
8181
color.Info.Block(message)
@@ -85,6 +85,6 @@ func logRequest(handler http.Handler) http.Handler {
8585
w.Header()[k] = v
8686
}
8787
w.WriteHeader(rec.Code)
88-
rec.Body.WriteTo(w)
88+
_, _ = rec.Body.WriteTo(w)
8989
})
9090
}

0 commit comments

Comments
 (0)