最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

python - How to make urllib use my own network code for the actual http GETPUT... operations? - Stack Overflow

matteradmin5PV0评论

I need to configure urllib in Anaconda Python 3.6 to use my own python code to do the actual GET, PUT, ... operations. The solution will be native python code and wrap the curl cli to do the acutal operation.

I'm working in a highly restrictive environment where I cannot install any software on my workstation. This limits me to Anaconda Python 3.6 with no ability to install pip modules. In this environment, I and my colleagues are using a set of python programs to collect information from internal APIs via an internal proxy. This proxy will soon be switched from basic authentication to NTLM authentication, which is not supported by Anaconda Python 3.6.

In the search for a solution, we noticed, that the 'curl' that comes with git-bash on our workstation does support NTLM authentication and can access our APIs. I made a small POC python module to wrap the curl cli tool do http requests and it worked fine. Now I'm searching for a way to use the curl tool without the need to completely rewrite all our existing code. I've already experimented with deriving classes from urllib.request.BaseHandler and urllib.request.HTTPBaseHandler, but apparently they're not meant to replace the actual networking code.

So, what would be your approach to make urllib use the curl cli command to do the actual requests? I'm aware that wrapping curl is horrible and I'm very open for alternative solutions, as long as they don't require additional software installation.

Post a comment

comment list (0)

  1. No comments so far