Is there a chance that request.remote_ip might return null?

Are there any instances that request.remote_ip or request.ip can return nil ?

+6
source share
1 answer

According to the rail source , it looks like remote_ip obtained from 3 separate headers, HTTP_CLIENT_IP , HTTP_X_FORWARDED_FOR and REMOTE_ADDR . Thus, if you are worried that you may receive a request that does not have any of these headers, then it looks like remote_ip might be nil (it looks something like the ip rack implementation). From what I read, it is safe enough to assume that the REMOTE_ADDR header will be present in most HTTP requests, so it is unlikely that any of these values โ€‹โ€‹will be zero.

+3
source

All Articles