tomasen / realip

a golang library that can get client's real public ip address from http request headers
MIT License
221 stars 47 forks source link

Refactor and add test case #2

Closed on99 closed 9 years ago

tomasen commented 9 years ago

Great. Thanks

Just 2 small problems to discuss:

I think hdrForwardedFor := strings.Replace(hdr.Get("X-Forwarded-For"), " ", "", -1) is less clear than strings.TrimSpace(p) after split. might be even less efficiency.

And also len(hdrForwardedFor)+len(hdrRealIP) <= 0 vs len(hdrForwardedFor) == 0 && len(hdrRealIP) == 0, seems also less clear and less efficiency.

on99 commented 9 years ago

Yes you are right on this issue. I've already updated the code accordingly