Skip to content

Commit

Permalink
pass build
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasen committed Dec 6, 2015
1 parent a1a7309 commit b20efed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"net/http"
"os"
"strings"
"runtime"
"runtime/debug"
"strconv"
Expand Down Expand Up @@ -179,10 +180,10 @@ func handleConn(c net.Conn) {

// check if it's HTTP request
if bytes.Contains(line, []byte("HTTP")) {
cipherAddr = []byte[]
hdrXxf = "X-Forwarded-For: " + ipAddrFromRemoteAddr(conn.RemoteAddr().String());
hdrXxf := "X-Forwarded-For: " + ipAddrFromRemoteAddr(c.RemoteAddr().String());
header = bytes.NewBuffer(line)
header.Write([]byte("\n"))
cipherAddr = []byte{}
for {
line, isPrefix, err := rdr.ReadLine()
if err != nil || isPrefix {
Expand All @@ -208,7 +209,7 @@ func handleConn(c net.Conn) {
return
}
if len(hdrXxf) == 0 {
header.Write([]bytehdrXxf))
header.Write([]byte(hdrXxf))
header.Write([]byte("\n"))
}
header.Write(line)
Expand Down
5 changes: 4 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ func TestHTTPServer(t *testing.T) {
client := &http.Client{}
req, _ := http.NewRequest("GET", "http://"+string(_defaultFrontdAddr), nil)
req.Header.Set(string(_cipherRequestHeader), string(cipherAddr))
res, _ := client.Do(req)
res, err := client.Do(req)
if err != nil {
panic(err)
}

b, err := ioutil.ReadAll(res.Body)
if err != nil {
Expand Down

0 comments on commit b20efed

Please sign in to comment.