httplib

Are urllib2 and httplib thread safe?

此生再无相见时 提交于 2019-11-26 06:43:30
问题 I\'m looking for information on thread safety of urllib2 and httplib . The official documentation (http://docs.python.org/library/urllib2.html and http://docs.python.org/library/httplib.html) lacks any information on this subject; the word thread is not even mentioned there... UPDATE Ok, they are not thread-safe out of the box. What\'s required to make them thread-safe or is there a scenario in which they can be thread-safe? I\'m asking because it\'s seems that using separate OpenerDirector

HTTPS connection Python

让人想犯罪 __ 提交于 2019-11-26 06:19:03
问题 I am trying to verify the that target exposes a https web service. I have code to connect via HTTP but I am not sure how to connect via HTTPS. I have read you use SSL but I have also read that it did not support certificate errors. The code I have got is from the python docs: import httplib conn = httplib.HTTPConnection(\"www.python.org\") conn.request(\"GET\", \"/index.html\") r1 = conn.getresponse() print r1.status, r1.reason Does anyone know how to connect to HTTPS? I already tried the

How to send POST request?

孤人 提交于 2019-11-26 02:16:53
问题 I found this script online: import httplib, urllib params = urllib.urlencode({\'number\': 12524, \'type\': \'issue\', \'action\': \'show\'}) headers = {\"Content-type\": \"application/x-www-form-urlencoded\", \"Accept\": \"text/plain\"} conn = httplib.HTTPConnection(\"bugs.python.org\") conn.request(\"POST\", \"\", params, headers) response = conn.getresponse() print response.status, response.reason 302 Found data = response.read() data \'Redirecting to <a href=\"http://bugs.python.org