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
3
votes
3 answers

POST method of httplib python gives an error "socket.gaierror: [Errno -2] Name or service not known"

The following code throws an error "socket.gaierror: [Errno -2] Name or service not known". import httplib, urllib attrs = urllib.urlencode({"username":"admin", "password":"admin"}) conn =…
ameet
  • 31
  • 2
3
votes
1 answer

Python urllib2 cannot open localhost on alternate port (not 80)? Error 10013

Here is my server.py: import BaseHTTPServer import SocketServer class TestRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(self): self.wfile.write("hello world at %s" % __file__) server = BaseHTTPServer.HTTPServer(('',…
Sergey Vasilyev
  • 3,919
  • 3
  • 26
  • 37
3
votes
1 answer

httplib binary data and UnicodeDecodeError in python 2.7

I just discovered that starting with Python 2.7, the httplib doesn't work anymore with binary data, breaking modules that where sending binary data over HTTP, one example being PyAMF Python bug: http://bugs.python.org/issue11898 PyAMF bug:…
sorin
  • 161,544
  • 178
  • 535
  • 806
3
votes
1 answer

Reading CONNECT headers

I'm using a proxy service (proxymesh) that puts useful information into the headers sent in response to a CONNECT request. For whatever reason, Python's httplib doesn't parse them: > CONNECT example.com:443 HTTP/1.1 > Host: example.com:443 > <…
Blender
  • 289,723
  • 53
  • 439
  • 496
3
votes
1 answer

How to send Multipart/related requests in Python to SOAP server?

I have to send a file to a SOAP server via a multipart/related HTTP POST. I have built the message from scratch like this: from email.mime.application import MIMEApplication from email.encoders import encode_7or8bit from email.mime.multipart import…
zapatilla
  • 1,711
  • 3
  • 22
  • 38
3
votes
1 answer

python httplib: getting the outgoing request headers

I do: con = HTTPConnection(SERVER_NAME) con.request('GET', PATH, HEADERS) resp = con.getresponse() For debugging reasons, I want to see the request I used (it's fields, path, method,..). I would expect there to be some sort of con.getRequest() or…
Guy
  • 14,178
  • 27
  • 67
  • 88
3
votes
1 answer

wants to get http request from python requests module

I wants to use python requests module to prepare http request and use http socket to send the request, So I can detect the connection problem. Can anyone suggest how should I retrieve raw request from python requests module(without sending…
user87005
  • 964
  • 3
  • 10
  • 27
3
votes
1 answer

Python - Using httplib to PUT JSON data

I am trying to perform a simple PUT with JSON data in the tastypie-Django Python application. But I'm seeing a 401 response error when I call it through code, but no error when I execute a cURL command from the terminal. I have the…
Brett
  • 11,637
  • 34
  • 127
  • 213
3
votes
1 answer

Why doesn't this `try` statement catch this `CannotSendRequest` error? python

try: serial_tx = bcl.sendrawtransaction(tx) except: raise ''other stuff'' The tx in the parenthesis is a raw transaction that is about to be broadcast to the network. This was the result - Internal Server Error:…
derrend
  • 4,176
  • 4
  • 27
  • 40
3
votes
2 answers

multiple requests in a single connection?

Is it possible to put multiple requests without breaking the connection using python httplib?. Like, can I upload a big file to the server in parts but in a single socket connection. I looked for answers. But nothing seemed so clear and…
asdfg
  • 2,541
  • 2
  • 26
  • 25
3
votes
3 answers

In Python, are there any libraries that mock out responses for httplib?

I'm currently using python_flickr_api to upload photos for my app: it uses httplib to perform a multipart POST request. Problem: I want to verify that the upload really is issued in an integration test by intercepting the POST request and creating a…
fatuhoku
  • 4,815
  • 3
  • 30
  • 70
3
votes
1 answer

python, send many HTTP requests through one network connection

I'm working on a python 2.7 script that must check in a Fedora Commons repository for the existence of some data in 20'000 objects. Basically this means sending 20'000 HTTP requests to 20'000 different urls on the repository (that runs on a Tomcat…
nIcO
  • 5,001
  • 24
  • 36
3
votes
1 answer

POST binary data using httplib cause Unicode exceptions

When i try to send an image with urllib2 the UnicodeDecodeError exception is occured. HTTP Post body: f = open(imagepath, "rb") binary = f.read() mimetype, devnull = mimetypes.guess_type(urllib.pathname2url(imagepath)) body = """Content-Length:…
anasdox
  • 629
  • 1
  • 7
  • 15
3
votes
0 answers

Python : Problems getting past the login page of an .aspx site

Problem: I have searched several websites/blogs/etc to find a solution but did not get to what I was looking for. The problem in short, is that I would like to scrape a site - but to get to that site - I have to get past the login page. What I…
Adil
  • 31
  • 3
2
votes
2 answers

urllib2 HTTPPasswordMgr not working - Credentials not sent error

The following python curl call has the following successful results: >>> import subprocess >>> args = [ 'curl', '-H', 'X-Requested-With: Demo', 'https://username:password@qualysapi.qualys.com/qps/rest/3.0/count/was/webapp' ]…
paragbaxi
  • 3,965
  • 8
  • 44
  • 58