Questions tagged [httplib]

A module from Python standard lib that defines classes which implement the client side of the HTTP and HTTPS protocols.

Official Python documentation at http://docs.python.org/2/library/httplib.html

328 questions
5
votes
1 answer

Python httplib SSL23_GET_SERVER_HELLO:unknown protocol

Note: this code works fine on Ubuntu but not on mac and instead of changing the mac/python settings locally I'm trying to make change to the code so it'll work everywhere.. import ssl import httplib httplib.HTTPConnection(server, port,…
Peter
  • 1,023
  • 4
  • 18
  • 23
5
votes
1 answer

Python: httplib getresponse issues many recv() calls

getresponse issues many recv calls while reading header of an HTML request. It actually issues recv for each byte which results in many system calls. How can it be optimized? I verified on an Ubuntu machine with strace dump. sample code: conn =…
nik_kgp
  • 1,112
  • 1
  • 9
  • 17
5
votes
1 answer

How to fix httplib.BadStatusLine exception?

URL = "MY HTTP REQUEST URL" XML = "0" parameter = urllib.urlencode({'XML': XML}) response = urllib.urlopen(URL, parameter) print response.read() IOError: ('http protocol error', 0, 'got a bad status line', None) I am trying to send…
Takkun
  • 6,131
  • 16
  • 52
  • 69
4
votes
1 answer

Python: issue in displaying as a list httplib.HTTPMessage

I have a small problem here. So, I am writing some calls for a well known REST API. Everything is going well, except the fact that I want all the response to be displayed as a list(which is better for me to manipulate). My function is this: import…
4
votes
1 answer

I try to install httplib on my python but I am getting an error

$ pip install httplib Collecting httplib Could not find a version that satisfies the requirement httplib (from versions: ) No matching distribution found for httplib How to make it work?
Mukesh
  • 51
  • 1
  • 6
4
votes
2 answers

python: httplib error: can not send headers

conn = httplib.HTTPConnection('thesite') conn.request("GET","myurl") conn.putheader('Connection','Keep-Alive') #conn.putheader('User-Agent','Mozilla/5.0(Windows; u; windows NT 6.1;en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome//5.0.375.126…
Grey
  • 1,365
  • 4
  • 23
  • 34
4
votes
1 answer

Adding server certificate validation to httplib.HTTPSConnection

I've found that httplib.HTTPSConnection doesn't perform an automatic server certificate check. As far as I've understood the problem, I need to add that functionality manually, e.g. by subclassing this class as described here. As I'm using…
Johannes Charra
  • 29,455
  • 6
  • 42
  • 51
4
votes
1 answer

gsutil cp communications issues

Every friday I run a gsutil 4.3 cp -n -L -R command (python version is 2.7.5) in order to upload 5 GB of data (48 files no larger than 512 MB each one) from a Windows 7 Enterprise to GCS. Since August 8th, I began to get GSutil errors as the…
4
votes
2 answers

How do I send and receive HTTP POST requests in Python?

I have these two Python scripts I'm using to attempt to work out how to send and receive POST requests in Python: The Client: import httplib conn = httplib.HTTPConnection("localhost:8000") conn.request("POST",…
user573949
  • 750
  • 3
  • 9
  • 18
4
votes
2 answers

Log onto a Website and select options using Python

I am trying to log onto a website using Python. I have written the code to connect to the target but I need to login and select a button on the website and wait for a response. I have looked at the HTTP Protocol in Python and was thinking of using…
chrisg
  • 40,337
  • 38
  • 86
  • 107
4
votes
2 answers

does httplib reuse TCP connections?

I'm using httplib to grab bunch of resources from a website and i want it at minimum cost, so i set 'Connection: keep-alive' HTTP header on my requests but i'm not sure it actually uses the same TCP connection for as many requests as the webserver…
sia
  • 401
  • 3
  • 8
  • 20
4
votes
1 answer

How to handle multiple Set-Cookie header in HTTP response

I'm trying to write simple proxy server for some purpose. In it I use httplib to access remote web-server. But there's one problem: web server returns TWO Set-Cookie headers in one response, and httplib mangles them together in…
Andy
  • 3,139
  • 4
  • 21
  • 13
4
votes
1 answer

Unknown error in sixohsix's Twitter API for Python

I have a small script that repeatedly (hourly) fetches tweets from the API, using sixohsix's Twitter Wrapper for Python. I am successful with handling most, if not all of the errors coming from the Twitter API, i.e. all the 5xx and 4xx stuff.…
grssnbchr
  • 2,877
  • 7
  • 37
  • 71
4
votes
1 answer

A socket operation was attempted to an unreachable network in python httplib

I am trying to make a REST client from django using httplib . But it is refusing the connection I tried the following import hashlib import hmac from django.shortcuts import render_to_response from django.template import RequestContext def…
hangman
  • 865
  • 5
  • 20
  • 31
3
votes
3 answers

Suds Error: BadStatusLine in httplib

I am using suds 0.3.6. When creating a suds client, I randomly get an error: httplib.py, _read_status(), line 355, class httplib.BadStatusLine' Here is the code used to create the client: imp =…