Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy Response Headers 301 Dropbox URL Request #14

Open
savanr opened this issue Aug 24, 2018 · 3 comments
Open

Proxy Response Headers 301 Dropbox URL Request #14

savanr opened this issue Aug 24, 2018 · 3 comments

Comments

@savanr
Copy link

savanr commented Aug 24, 2018

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?

@zerowidth
Copy link
Owner

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.

@savanr
Copy link
Author

savanr commented Aug 29, 2018

@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

@zerowidth
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants