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

How to get port number from an HTTP response, using Python?

I am trying to simulate Network Address Translation for some test code. I am mapping virtual users to high port numbers, then, when I want to test a request from user 1, I send it from port 6000 (user 2, from 6001, etc). However, I can't see the…
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551
2
votes
1 answer

Python httplib retrieve json object from getresponse()

So I currently working on a POST request to an api. conn = httplib.HTTPSConnection('api.syncano.io') conn.request(method="POST", url=url, body=postdata, headers=headers) resp = conn.getresponse() I used resp.read() but it returns me a string. Are…
Clueless_Coder
  • 515
  • 2
  • 7
  • 16
2
votes
1 answer

Convert curl to httplib headers

I have the following "curl" command working with Mailgun: curl -s --user 'api:key-xxxxxx' \ https://api.mailgun.net/v3/sandboxyyyyyy.mailgun.org/messages \ -F from='Excited User ' \ -F…
alextc
  • 3,206
  • 10
  • 63
  • 107
2
votes
1 answer

Python httplib.HTTPSConnection and password

I use httplib.HTTPSConnection with private key: h = httplib.HTTPSConnection(url, key_file='../cert/priv.pem', cert_file='../cert/srv_test.crt') Then I am asked to enter the password to that private key. Is there any option to enter such password…
Michał Niklas
  • 53,067
  • 18
  • 70
  • 114
2
votes
1 answer

Requests/httplib/urllib return 3 different results

I'm making a GET request to OrientDB via their HTTP API, which seems to return 3 different results with the 3 aforementioned modules. uri = 'http://localhost:2480/query/Test1/sql/Select from Person' # Requests import requests r = requests.get(uri,…
thomas
  • 1,133
  • 1
  • 12
  • 31
2
votes
1 answer

Upload a file with python using httplib

conn = httplib.HTTPConnection("www.encodable.com/uploaddemo/") conn.request("POST", path, chunk, headers) Above is the site "www.encodable.com/uploaddemo/" where I want to upload an image. I am better versed in php so I am unable to understand the…
Harshit Sharma
  • 123
  • 2
  • 4
  • 7
2
votes
1 answer

python httplib and broken tcp connection

How do I find out if a connection has been broken using the httplib library? Seems like something so basic yet I can't find the answer on here or google.
Xavier
  • 8,828
  • 13
  • 64
  • 98
2
votes
1 answer

How to catch any socket error in Python?

I am trying to check if a URL to a jpg is real. This code works, returns Trueif the jpg exists: import httplib def exists(site, path): conn = httplib.HTTPConnection(site) conn.request('HEAD', path) response = conn.getresponse() …
ian-campbell
  • 1,605
  • 1
  • 20
  • 42
2
votes
1 answer

Using Python requests to POST to a cgi script

I am currently using the python library httplib to pass POST requests to a cgi script. # Make web call to CGI script user_agent = r'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = {'User-Agent' : user_agent, "Content-type":…
Christopher Spears
  • 1,105
  • 15
  • 32
2
votes
1 answer

How do I handle rate limiting in the Dropbox API?

The Dropbox API docs state that in the event of being rate limited, a 503 HTTP status code will be returned, with a "Retry-After" header. However, in what I suspect is a case of rate limiting, this is the actual reponse I get: [503] Error parsing…
jl6
  • 6,110
  • 7
  • 35
  • 65
2
votes
0 answers

How can I create https connection on python 2.7?

The situation I'm trying to connect to a server on https protocol with python script. Could someone give me the working example that sends a GET request to https server, or web resource to how to create https connection with python? An attempt so…
inherithandle
  • 2,614
  • 4
  • 31
  • 53
2
votes
1 answer

what is the proper way to set a global socket timeout in python?

I am using a number of different libraries, which each of which use different underlying ways to make socket connections, like urllib3, requests, and httplib. this is in python 2.7.5. periodically, the program gets hung up in one of the libraries…
rbp
  • 1,850
  • 15
  • 28
2
votes
2 answers

SocksiPy fails when connecting throug Tor

Tried the 3 following methods to control Tor: using TorCtl/urllib2: Python script Exception with Tor using socks/httplib: http://www.youtube.com/watch?v=KDsmVH7eJCs using socks/urllib2: Python urllib over TOR? Each of them fails w/ same error…
2
votes
1 answer

How can I disable automatically following redirects using python's httplib2?

I would like to disable httplib2 from following redirects when I make a GET request to some site. Is this possible?
Popcorn
  • 5,188
  • 12
  • 54
  • 87
2
votes
1 answer

httplib vs urllib2 and cookies

I like urllib2 for automated routine operations, like cookie handling (with cookielib.CookieJar) or redirects processing. But i also like httplib for the low-level control that programmer have. For example, with httplib i can control for the order…
pavelkolodin
  • 2,859
  • 3
  • 31
  • 74