httplib2

Handling authentication and proxy servers with httplib2

末鹿安然 提交于 2019-12-10 23:33:54
问题 I'm attempting to test interactions with a Nexus server that requires authentication for the operations I intend to use, but I also need to handle an internal proxy server. Based on my (limited) understanding I can add multiple handlers to the opener. However I'm still getting a 401 response. I've checked the username and password are valid. I'm not certain if cookies are required to do this and if so how they'd be included. Any suggestions? baseUrl = 'server:8070/nexus-webapp-1.3.3/service

Intermittent “sslv3 alert handshake failure” under Python

北城余情 提交于 2019-12-10 04:04:11
问题 I have a REST API written in Java running under JBoss. Recently we updated our JVM from 1.6 to 1.7. This started to cause issues with only our Python clients which were connecting. Intermittently, Python clients are getting handshake failures. We wrote a very simple test which reproduces the problem: import httplib2 for i in range(1,500): print i response, content = httplib2.Http(disable_ssl_certificate_validation=True).request('https://server.com:8443',) Give the following output: . . . 64

httplib2, how to set more than one cookie?

狂风中的少年 提交于 2019-12-09 18:18:43
问题 As you are probably aware, more often than not, an HTTP server will send more than just a session_id cookie; however, httplib2 handles cookies with a dictionary, like this: response, content = http.request(url, 'GET', headers=headers) headers = {'Cookie': response['set-cookie']} url = 'http://www.example.com/home' response, content = http.request(url, 'GET', headers=headers) So, how do I set the extra cookies? If handled with a dictionary, I can't have double Cookie keys :S. Thanks for your

How to do mutual certificate authentication with httplib2

家住魔仙堡 提交于 2019-12-09 05:47:15
问题 I'm using httplib2 to make a request from my server to another web service. We want to use mutual certificate authentication. I see how to use a certificate for the outgoing connection ( h.set_certificate ), but how do I check the certificate used by the answering server? This ticket seems to indicate that httplib2 doesn't do it itself, and has only vague suggestions about where to look. Is it possible? Am I going to have to hack at a lower level? 回答1: Here's the code my co-worker Dave St.

python jsonrpc2 client example connecting to remote hello world example using httplib?

流过昼夜 提交于 2019-12-08 07:56:08
问题 I am trying to create a jsonrpc2 server that will accept json over http , process the data and return json back to the requesting client. I am quite new to rpc servers and wsgi and have only used it as part of a webframework like django. I am attempting to follow the example given with the jsonrpc2 documentation. The first step is creating a file hello.py def greeting(name): return dict(message="Hello, %s!" % name) The next step involves starting the service runjsonrpc2 hello runserver :8080

Can I do preemptive authentication with httplib2?

拥有回忆 提交于 2019-12-07 05:43:58
问题 I need to perform preemptive basic authentication against an HTTP server, i.e., authenticate right away without waiting on a 401 response. Can this be done with httplib2? Edit: I solved it by adding an Authorization header to the request, as suggested in the accepted answer: headers["Authorization"] = "Basic {0}".format( base64.b64encode("{0}:{1}".format(username, password))) 回答1: Add an appropriately formed 'Authorization' header to your initial request. 回答2: This also works with the built

Command line URL fetch with JavaScript capabliity

邮差的信 提交于 2019-12-05 23:54:47
I use curl, in php and httplib2 in python to fetch URL. However, there are some pages that use JavaScript (AJAX) to retrieve the data after you have loaded the page and they just overwrite a specific section of the page afterward. So, is there any command line utility that can handle JavaScript? To know what I mean go to: monster.com and try searching for a job. You'll see that the Ajax is getting the list of jobs afterward. So, if I wanted to pull in the jobs based on my keyword search, I would get the page with no jobs. But via browser it works. Get FireBug and see the URL for that Ajax

Can I do preemptive authentication with httplib2?

喜你入骨 提交于 2019-12-05 09:47:06
I need to perform preemptive basic authentication against an HTTP server, i.e., authenticate right away without waiting on a 401 response. Can this be done with httplib2? Edit: I solved it by adding an Authorization header to the request, as suggested in the accepted answer: headers["Authorization"] = "Basic {0}".format( base64.b64encode("{0}:{1}".format(username, password))) Add an appropriately formed 'Authorization' header to your initial request. This also works with the built-in httplib (for anyone wishing to minimize 3rd-party libs/modules). I am using it to authenticate with our Jenkins

How do I make calls to AWS with Python 3 and httplib2 on Windows 7?

为君一笑 提交于 2019-12-05 09:35:43
I am using httplib2 to make calls to Amazon Web Services (AWS): http = httplib2.Http(cache='.cache') response, content = http.request('https://sdb.amazonaws.com/...') However it fails looking for CAs (I think): File "C:\Python32\lib\site-packages\httplib2\__init__.py", line 1059, in request self.disable_ssl_certificate_validation) File "C:\Python32\lib\site-packages\httplib2\__init__.py", line 772, in __init__ context.load_verify_locations(ca_certs) IOError: [Errno 2] No such file or directory My questions: Is there something I need to do to configure my OS and environment for this to work? I

Google API + proxy + httplib2

与世无争的帅哥 提交于 2019-12-05 07:12:25
I'm currently running a script to pull data from Google Analytics with googleapiclient Phyton package (that is based on httplib2 client object) --> My script works perfectly without any proxy. But I have to put it behind my corporate proxy, so I need to adapt my httplib2.Http() object to embed proxy information. Following httplib2 doc 1 I tried: pi = httplib2.proxy_info_from_url('http://user:pwd@someproxy:80') httplib2.Http(proxy_info=pi).request("http://www.google.com") But it did not work. I always get a Time out error, with or without the proxy info (so proxy_info in parameter is not taken