modify remote addr

This commit is contained in:
wenyekui 2014-08-04 10:28:09 +08:00
parent 9ad7095e2d
commit 1655f48652
1 changed files with 4 additions and 8 deletions

View File

@ -19,6 +19,9 @@ var allowedContentTypes = map[string]struct{}{
"bson": struct{}{}, "bson": struct{}{},
"msgpack": struct{}{}, "msgpack": struct{}{},
} }
var unsopportedCommands = map[string]struct{}{
"": struct{}{},
}
type httpClient struct { type httpClient struct {
app *App app *App
@ -55,14 +58,7 @@ func newClientHTTP(app *App, w http.ResponseWriter, r *http.Request) {
} }
func (c *httpClient) addr(r *http.Request) string { func (c *httpClient) addr(r *http.Request) string {
addr := r.Header.Get("X-Forwarded-For") return r.RemoteAddr
if addr == "" {
addr = r.Header.Get("X-Real-IP")
if addr == "" {
addr = r.Header.Get("Remote-Addr")
}
}
return addr
} }
func (c *httpClient) makeRequest(app *App, r *http.Request, w http.ResponseWriter) (*requestContext, error) { func (c *httpClient) makeRequest(app *App, r *http.Request, w http.ResponseWriter) (*requestContext, error) {