Wasn't the check against res above sufficient? 

I don't understand why are you adding this specific check against res.nil? here. On the other hand, even the same module has other send_request_* calls with the same pattern and have not been changed. Should them be changed too?