Proxy Response Headers 301 Dropbox URL Request
I am using proxy to load dropbox URL. My purpose is to load URL and display image on canvas. It was working fine but since last few days it returns me 301 status.
streaming_proxy.rb
if request.path.start_with?('/proxy')
request.params['uri']
end
I am receiving,
[Rack::StreamingProxy] Parent process 11548 forked a child process 13396.
[Rack::StreamingProxy] Child starting request to https://www.dropbox.com/s/5l4vvb413squt2f/b4B86CN.jpg?dl=0&raw=1
[Rack::StreamingProxy] Child got response: Net::HTTPMovedPermanently
[Rack::StreamingProxy] Child process 13396 returning Status = 301.
[Rack::StreamingProxy] +-------------------------------------------------------------
[Rack::StreamingProxy] | Proxy Response Headers:
[Rack::StreamingProxy] Parent received: Status = 301.
[Rack::StreamingProxy] Parent received: Reponse has body? = true.
What wrong I am doing?
The ruby Net::HTTP client doesn't appear to follow redirects, so you'd have to handle that yourself either up-front by getting the new URLs for the files in dropbox, or modifying the library to follow redirects. Changing the library would mean a change to session.rb to add (configurable?) redirect-following to proxied requests.
@zerowidth Thanks for your reply. I tried with requesting new URL for file, same error I am getting.
[Rack::StreamingProxy] Parent process 5220 forked a child process 6816.
[Rack::StreamingProxy] Child starting request to https://www.dropbox.com/s/ubkyjp1xygc8jng/landscape-meadow-field-mountains-66874.jpeg?dl=0&raw=1
[Rack::StreamingProxy] Child got response: Net::HTTPMovedPermanently
[Rack::StreamingProxy] Child process 6816 returning Status = 301.
How can I can handle using Net::HTTP by changing session.rb? Is there any change in redirection to streaming_proxy.rb?
This endpoint I am referring to : https://www.dropbox.com/developers/documentation/http/documentation#sharing-create_shared_link_with_settings
The proxy uses Net::HTTP, which does not follow redirects. You'll have to do proxying yourself, or change the proxy request in session.rb to follow redirects. It's already configured as a loop, so "follow a redirect" would be a retry there.