Giter VIP home page Giter VIP logo

Comments (9)

ZzZombo avatar ZzZombo commented on August 24, 2024 1

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.

carsonyl avatar carsonyl commented on August 24, 2024

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.

ZzZombo avatar ZzZombo commented on August 24, 2024

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.

carsonyl avatar carsonyl commented on August 24, 2024

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.

ZzZombo avatar ZzZombo commented on August 24, 2024

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.

carsonyl avatar carsonyl commented on August 24, 2024

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.

ZzZombo avatar ZzZombo commented on August 24, 2024

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.

ZzZombo avatar ZzZombo commented on August 24, 2024

I also think it merits checking only the first and the last responses in the chain for content type.

from pypac.

carsonyl avatar carsonyl commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.