httplib

python httplib Name or service not known

六眼飞鱼酱① 提交于 2019-11-27 02:52:54
问题 I'm trying to use httplib to send credit card information to authorize.net. When i try to post the request, I get the following traceback: File "./lib/cgi_app.py", line 139, in run res = method() File "/var/www/html/index.py", line 113, in ProcessRegistration conn.request("POST", "/gateway/transact.dll", mystring, headers) File "/usr/local/lib/python2.7/httplib.py", line 946, in request self._send_request(method, url, body, headers) File "/usr/local/lib/python2.7/httplib.py", line 987, in

Python script to see if a web page exists without downloading the whole page?

佐手、 提交于 2019-11-27 01:37:22
问题 I'm trying to write a script to test for the existence of a web page, would be nice if it would check without downloading the whole page. This is my jumping off point, I've seen multiple examples use httplib in the same way, however, every site I check simply returns false. import httplib from httplib import HTTP from urlparse import urlparse def checkUrl(url): p = urlparse(url) h = HTTP(p[1]) h.putrequest('HEAD', p[2]) h.endheaders() return h.getreply()[0] == httplib.OK if __name__=="__main_

Python httplib ResponseNotReady

落花浮王杯 提交于 2019-11-26 22:44:59
问题 I'm writing a REST client for elgg using python, and even when the request succeeds, I get this in response: Traceback (most recent call last): File "testclient.py", line 94, in <module> result = sendMessage(token, h1) File "testclient.py", line 46, in sendMessage res = h1.getresponse().read() File "C:\Python25\lib\httplib.py", line 918, in getresponse raise ResponseNotReady() httplib.ResponseNotReady Looking at the header, I see ('content-length', '5749'), so I know there is a page there,

HTTPS connection Python

自闭症网瘾萝莉.ら 提交于 2019-11-26 19:38:06
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 HTTPSConenction but it responds with an error code claiming httplib does not have attribute HTTPSConnection. I

Proxying to another web service with Flask

不羁的心 提交于 2019-11-26 19:17:32
问题 I want to proxy requests made to my Flask app to another web service running locally on the machine. I'd rather use Flask for this than our higher-level nginx instance so that we can reuse our existing authentication system built into our app. The more we can keep this "single sign on" the better. Is there an existing module or other code to do this? Trying to bridge the Flask app through to something like httplib or urllib is proving to be a pain. 回答1: I have an implementation of a proxy

Are urllib2 and httplib thread safe?

99封情书 提交于 2019-11-26 18:58:28
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 in each thread not sharing HTTP connection among threads would suffice to safely use these libs in threads

httplib CannotSendRequest error in WSGI

吃可爱长大的小学妹 提交于 2019-11-26 14:28:18
问题 I've used two different python oauth libraries with Django to authenticate with twitter. The setup is on apache with WSGI. When I restart the server everything works great for about 10 minutes and then the httplib seems to lock up (see the following error). I'm running only 1 process and 1 thread of WSGI but that seems to make no difference. I cannot figure out why it's locking up and giving this CannotSendRequest error. I've spent a lot of hours on this frustrating problem. Any hints

error: can&#39;t start new thread

∥☆過路亽.° 提交于 2019-11-26 14:06:59
问题 I have a site that runs with follow configuration: Django + mod-wsgi + apache In one of user's request, I send another HTTP request to another service, and solve this by httplib library of python. But sometimes this service don't get answer too long, and timeout for httplib doesn't work. So I creating thread, in this thread I send request to service, and join it after 20 sec (20 sec - is a timeout of request). This is how it works: class HttpGetTimeOut(threading.Thread): def __init__(self,*

IncompleteRead using httplib

↘锁芯ラ 提交于 2019-11-26 14:00:28
问题 I have been having a persistent problem getting an rss feed from a particular website. I wound up writing a rather ugly procedure to perform this function, but I am curious why this happens and whether any higher level interfaces handle this problem properly. This problem isn't really a show stopper, since I don't need to retrieve the feed very often. I have read a solution that traps the exception and returns the partial content, yet since the incomplete reads differ in the amount of bytes

Python-Requests close http connection

此生再无相见时 提交于 2019-11-26 09:35:30
问题 I was wondering, how do you close a connection with Requests (python-requests.org)? With httplib it\'s HTTPConnection.close() , but how do I do the same with Requests? Code is below: r = requests.post(\"https://stream.twitter.com/1/statuses/filter.json\", data={\'track\':toTrack}, auth=(\'username\', \'passwd\')) for line in r.iter_lines(): if line: self.mongo[\'db\'].tweets.insert(json.loads(line)) Thanks in advance. 回答1: As discussed here, there really isn't such a thing as an HTTP