Are there any instances that request.remote_ip
or request.ip
can return nil
?
According to the rails source it looks like the remote_ip
is obtained from 3 separate headers, HTTP_CLIENT_IP
, HTTP_X_FORWARDED_FOR
, and REMOTE_ADDR
. So, if you're concerned that you might receive a request that has none of those headers, then it looks like it's possible for remote_ip
to be nil (looks pretty much the same way in the rack implementation of ip
). From what I've read it's pretty safe to assume the REMOTE_ADDR
header will be present in most HTTP requests, so it's unlikely either of those values will be nil.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With