rack-streaming-proxy icon indicating copy to clipboard operation
rack-streaming-proxy copied to clipboard

Proxy Response Headers 301 Dropbox URL Request

Open savanr opened this issue 7 years ago • 3 comments

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?

savanr avatar Aug 24 '18 07:08 savanr

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 avatar Aug 24 '18 15:08 zerowidth

@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

savanr avatar Aug 29 '18 05:08 savanr

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.

zerowidth avatar Aug 29 '18 23:08 zerowidth