Search code examples
rubyrubygemsnet-httpfaraday

How do I retrieve the response.URL using Faraday gem?


I'm using Faraday to check for broken links, and I want to retrieve the response.URL of the links I'm querying, however, I am not able to find any documentation and examples to do so.

I was able to do this on the front-end using Javascript's Fetch API (Response.url: https://developer.mozilla.org/en-US/docs/Web/API/Response/url) but that is not an option now as I am required to do this on the backend using Faraday only.

Is this even possible with Faraday? If so, how do I implement it? Or kindly point me to the right documentation.


Solution

  • There are lots of class variables instantiated in the response object: response.env You might be looking at:

    response.env.url.to_s