Comments (9)
OK, I'm gonna apologize for false report. The application didn't get a (valid, expected) response from the remote server. By the time I altered the function, the issue was resolved somehow, I think it's because we started to supply an user agent string that wasn't banned per the PAC script policy and made sure to abide to the rate limits.
from pypac.
Can you clarify what you mean about Content-Type
handling? Redirect handling is likely a duplicate of #37, but would be nice to have for sure.
from pypac.
Your code only needs to have resp = sess.get(pac_url, timeout=timeout,
allow_redirects = True
)
in api.py
added in the code in order to allow redirects, but given there is now a response for each redirect and the final URL, you need to check each Content-Type
for validity, if at least one is acceptable, then the content type check must succeed for the whole redirection chain. And no, it's not a duplicate of the linked issue, it's for the PAC file itself, not for purely a HTTP redirecting handling.
from pypac.
Requests defaults allow_redirects
to True if not specified, so my understanding is that https://github.com/carsonyl/pypac/blob/master/pypac/api.py#L157 should already follow redirects, and the content type check only happens at the end.
from pypac.
I do not know what's the deal with that, I did check the docs myself beforehand, but adding that absolutely does solve the redirect issue for me, and I'm not really motivated to find out whether that's a case of outdated docs or a bug or something else. And I also do absolutely see now how the content type check is done only once, only for the final response. That's the part that needs to be changed for robustness sake if redirects are allowed.
from pypac.
Explicitly setting allow_redirects
to true is easy. But checking each redirection for PAC Content-Type
match does not sound correct: why would the server return PAC headers and body but also HTTP 301/302 and Location
header? Besides, that likely needs allow_redirects
to be false, with pypac manually handling redirects in order to implement such logic.
from pypac.
Because it's how just how it is in the wild. You seem to misunderstand the issue at hand, The Antizapret PAC file is first served with the appropriate for a PAC file content type in the redirect response (no body), then the actual, final URL is served with a content type of a regular JavaScript file and the body of the PAC file.
from pypac.
I also think it merits checking only the first and the last responses in the chain for content type.
from pypac.
I've never heard of the behaviour you describe. It sounds very strange. I think it's best if you keep using your workaround (I assume you have one). I don't want to make potentially major code changes for this, especially because I don't have a repro to test against.
from pypac.
Related Issues (20)
- dnsDomainIs behavior
- Pypac module is not working in Mac OS with cx_freeze HOT 4
- Allow setting the client ip address HOT 3
- Drop Python 3.4 support
- can't get the pac HOT 1
- tld 0.11+ is not python 2.7 compatible HOT 1
- multiple source ip addresss test HOT 1
- dnsDomainIs matching not correct
- Use a cache for domain lookup HOT 1
- Pypac is not working on Mac without installing install certificates.command and update shell profile.command HOT 1
- PyPAC does not work with file url that uses IP and does not use domain HOT 3
- replace `tld` requirement which is under GPL2 license HOT 5
- no useful pac function to use in the pypac, hope one day can come true the function HOT 1
- import error observed when "let" keyword is used to create a global variable HOT 2
- Doesn't accept `https://antizapret.prostovpn.org/proxy.pac` as valid script HOT 3
- Make the script validity check optional HOT 4
- consider that TLDExtract cache will be used by default when evaluating WPAD HOT 3
- When get_pac returns None, there is no way to tell if there is no PAC, or if error occurred HOT 3
- Is it possible to reduce the number of dependencies? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pypac.