httplib2

104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN?

We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read: (104, 'Connection reset by peer') When I listen in with wireshark, the "good" and "bad" responses look very similar: Because of the s...

Does the Python library httplib2 cache URIs with GET strings?

In the following example what is cached correctly? Is there a Vary-Header I have to set server-side for the GET string? import httplib2 h = httplib2.Http(".cache") resp, content = h.request("http://test.com/list/") resp, content = h.request("http://test.com/list?limit=10") resp, content = h.request("http://test.com/list?limit=50") ...

Is Twisted an httplib2/socket replacement?

Many python libraries, even recently written ones, use httplib2 or the socket interface to perform networking tasks. Those are obviously easier to code on than Twisted due to their blocking nature, but I think this is a drawback when integrating them with other code, especially GUI one. If you want scalability, concurrency or GUI integr...

Handling authentication and proxy servers with httplib2

I'm attempting to test interactions with a Nexus server that requires authentication for the operations I intend to use, but I also need to handle an internal proxy server. Based on my (limited) understanding I can add multiple handlers to the opener. However I'm still getting a 401 response. I've checked the username and password are v...

Implementing a custom Python authentication handler

The answer to a previous question showed that Nexus implement a custom authentication helper called "NxBASIC". How do I begin to implement a handler in python? Update: Implementing the handler per Alex's suggestion looks to be the right approach, but fails trying to extract the scheme and realm from the authreq. The returned value f...

how to fix or make an exception for this error

I'm creating a code that gets image's urls from any web pages, the code are in python and use BeutifulSoup and httplib2. When I run the code, I get the next error: Look me http://movies.nytimes.com (this line is printed by the code) Traceback (most recent call last): File "main.py", line 103, in <module> visit(initialList,profu...

command line URL fetch with JavaScript capabliity

Hi, I use curl, in php and httplib2 in python to fetch URL. However, there are some pages that use JavaScript (AJAX) to reterive the data after you have loaded the page and they just overwrite a specific section of the page afterward. So, is there any command line utility that can handle JavaScript? To know what I mean go to: monste...

Best practise when using httplib2.Http() object

I'm writing a pythonic web API wrapper with a class like this import httplib2 import urllib class apiWrapper: def __init__(self): self.http = httplib2.Http() def _http(self, url, method, dict): ''' Im using this wrapper arround the http object all the time inside the class ''' params = urllib.url...

Downloading compressed content over HTTP using Python

How do I take advantage of HTTP 1.1's compression when downloading web pages using Python? I am currently using the built-in urllib module for downloading web content. Reading through the documentation I couldn't find any information that is indeed using compression. Is it already built-in into urllib or is there another library that ...

httplib2, how to set more than one cookie?

As you are probably aware, more often than not, an HTTP server will send more than just a session_id cookie; however, httplib2 handles cookies with a dictionary, like this: response, content = http.request(url, 'GET', headers=headers) headers = {'Cookie': response['set-cookie']} url = 'http://www.example.com/home' response, content...

httplib2 not found

sh-3.2# python -V Python 2.6.4 sh-3.2# python -c "import httplib2" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named httplib2 errr.. how to fix this? ...

httplib2 multiple connection request

Hy! I'm using httplib2 to simulate several connections to test load on my application. But the issue that I encounter is while testing several connections to my appication at the same time. I obtain the following error : AttributeError: 'NoneType' object has no attribute 'makefile'. I don't really understand why this problem occure...

Accessing python httplib2 over a network share in windows 7

I am trying to run python from a network share on windows 7. The network share is T: >t:\python-2.6.1\python Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import httplib2 httplib2\__init__.py:29: DeprecationWarning: the md5...

Using httplib2 in python 3 properly? (Timeout problems)

Hey, first time post, I'm really stuck on httplib2. I've been reading up on it from diveintopython3.org, but it mentions nothing about a timeout function. I look up the documentation, but the only thing I see is an ability to put a timeout int but there are no units specified (seconds? milliseconds? What's the default if None?) This is w...

Which is the best python library to make REST request like PUT, GET, DELETE, POST and how ?

Hi, I am bit confuse over set of libraries of pythons to connect with REST enabled web services. I have tried httplib, urllib and urllib2. I want to know how can methods like PUT, GET, POST, DELETE can be achieved using this library. Regards, Parthiv ...

Python Regex Help (httplib2 cookies)

Having the same problem as the poster of this question: http://stackoverflow.com/questions/1738227/httplib2-how-to-set-more-than-one-cookie The cookie looks like this.. PHPSESSID=8527b5532b6018aec4159d81f69765bd; path=/; expires=Fri, 19-Feb-2010 13:52:51 GMT, id=1578; expires=Mon, 22-Feb-2010 13:37:51 GMT, password=123456; expires=M...

how to follow meta refreshes in Python

Python's urllib2 follows 3xx redirects to get the final content. Is there a way to make urllib2 (or some other library such as httplib2) also follow meta refreshes? Or do I need to parse the HTML manually for the refresh meta tags? ...

How to do mutual certificate authentication with httplib2

I'm using httplib2 to make a request from my server to another web service. We want to use mutual certificate authentication. I see how to use a certificate for the outgoing connection (h.set_certificate), but how do I check the certificate used by the answering server? This ticket seems to indicate that httplib2 doesn't do it itself,...

Adding string to end of URL

To practise some more bits of python I've been having a go at the challenges on pythonchallenge.com In brief, this challenge as a first step requires one to load an html page from a url with a number at the end. The page contains a single line of text which has in it a number. That number is used to replace the existing one in the url, ...

httplib2 giving internal server error 500 with proxy

Following is the code and error it throws. It works fine without the proxy http = httplib2.Http() . When I try the same http proxy in Firefox, it works fine. Any pointers are highly appreciated! Usage : http = httplib2.Http(proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, '68.48.25.158', 25681)) main_url = 'http://www.mywebs...