return inside an ensure block uses to be a bad idea, the code after exception (if there is any) won't finish. Since the code block is small:

```ruby
m = res.get_cookies.match(/([\-\w\d]+)=((?:\d+\.){2}\d+)(?:$|,|;|\s)/)
```

I think would be a better idea to rescue the exceptions which I guess you're expecting there and handle them.