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 support? #3

Open
j3rwin opened this issue Feb 6, 2017 · 16 comments
Open

Proxy support? #3

j3rwin opened this issue Feb 6, 2017 · 16 comments

Comments

@j3rwin
Copy link
Contributor

j3rwin commented Feb 6, 2017

I tried to add proxy by editing sessionpool.py(L59) following this but when i run the script it would fetch the meta-data of the file but wouldn't download it(stuck at 0%)

Any ideas @avamsi ?

@avamsi
Copy link
Owner

avamsi commented Feb 6, 2017

it would fetch the meta-data
but wouldn't download

That's weird. Did you make any other changes? Maybe the HEAD request is being sent directly (i.e, without proxy).

I wasn't able to get SourceAddressAdapter work with a local SOCKS5 proxy server. Following code, which makes a simple HEAD request to example.org failed for me.
You said you were able to fetch the metadata, can you run the following code and see if it works for you?

import requests
import requests_toolbelt

proxies = {'http': 'socks5://host:port'}

requests.head('http://example.org', proxies=proxies)  # works with proxy

s = requests.Session()
s.mount('http://', requests_toolbelt.SourceAddressAdapter(local_ip))

s.head('http://example.org')  # works without proxy
s.head('http://example.org', proxies=proxies)  # raises exception

@j3rwin
Copy link
Contributor Author

j3rwin commented Feb 6, 2017

Yeah both are working fine...

Did you install the dependency - requests[socks]?

BTW I've also installed pysocks this may be the issue

@avamsi
Copy link
Owner

avamsi commented Feb 6, 2017

Did you install the dependency - requests[socks]?

I did.

Btw, I had (have?) the same problem with a local HTTP proxy server.
I actually ran into this problem a while back. I don't remember if it was before or after this commit, which seemingly added proxy support for SourceAddressAdapter.

Anyway, the error I'm facing is

OSError: [WinError 10049] The requested address is not valid in its context

which seems to be Windows-specific and possibly has something to do with local proxy servers I'm running. Are you using an external proxy server?

@j3rwin
Copy link
Contributor Author

j3rwin commented Feb 6, 2017

Are you using an external proxy server?

No its a local socks proxy created by ssh tunnel(to my vps)

Even I tried with my windows machine and I'm getting [WinError xxxx] for both http and socks proxy but strangely https proxy works fine!!!

@avamsi
Copy link
Owner

avamsi commented Feb 7, 2017

I tried to add proxy by editing sessionpool.py(L59) following this but when i run the script it would fetch the meta-data of the file but wouldn't download it(stuck at 0%)

Any ideas @avamsi ?

See if your proxy server is ignoring or otherwise somehow messing up range headers -- that's the only difference I can think of.

Given those simple proxy requests are failing for me, there's nothing much I can do to help.

@j3rwin
Copy link
Contributor Author

j3rwin commented Feb 7, 2017

See if your proxy server is ignoring or otherwise somehow messing up range headers

I don't think its possible as firewall blocks almost every port(except 22). So any connection bypassing proxy wont go through the firewall.(Using proxy is the only way to access internet)

@avamsi
Copy link
Owner

avamsi commented Feb 7, 2017

You seem to have misunderstood me. I'm not saying your proxy server is bypassed.
I'm saying it might not know how to handle range headers, which are used to download partial content.

@j3rwin
Copy link
Contributor Author

j3rwin commented Feb 7, 2017

it might not know how to handle range headers

If thats the case it should never download anything, right? But when when i use the script (with same proxy) with my mobile data connection its downloading the file. Let me know if I missed something

@avamsi
Copy link
Owner

avamsi commented Feb 7, 2017

But when i use the script (with same proxy) with my mobile data connection its downloading the file

Oh. I can't think of anything else that would cause the problem.

@j3rwin
Copy link
Contributor Author

j3rwin commented Feb 7, 2017

Okk , So probably a bug in requests?

@avamsi
Copy link
Owner

avamsi commented Feb 7, 2017

Okk , So probably a bug in requests?

Um, probably not. I mean it's not impossible but chances are, something is wrong on our end; a bug in requests_toolbelt; a bug in requests, in that order.

@j3rwin
Copy link
Contributor Author

j3rwin commented Feb 7, 2017

So no solutions for now, huh?

BTW do you have plans of making a gui or something?

@avamsi
Copy link
Owner

avamsi commented Feb 7, 2017

[...] do you have plans of making a gui [...]

I did at one point but later decided I just don't need it.
I don't care for the download history. (It's the only thing I can think of that can be added, as progress dialog and complete dialog are already present)
So, no.

@j3rwin
Copy link
Contributor Author

j3rwin commented Feb 7, 2017

Bored with the copy - pasting the url, I'm planning to make a browser extension(aria2c style) :p

Any suggestions over aria2c?

@avamsi
Copy link
Owner

avamsi commented Feb 14, 2017

I somehow missed your last comment. How is it coming along?

@j3rwin
Copy link
Contributor Author

j3rwin commented Feb 15, 2017

Haven't started it, yet. Broke my mobile firmware and had to spend almost a week on that + midsems are just a few days away :( .Will start after next week..

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