Git Product home page Git Product logo

httplib2's People

Contributors

alainv avatar cdent avatar djc avatar durin42 avatar jaraco avatar jcgregorio avatar

Watchers

 avatar

httplib2's Issues

support cache-control: max-stale and return stale responses

I am dealing with a fairly hostile API, that supports no caching headers
other than Date, and is quick to return 503s if used more frequently than
30-minutes intervals.

Returning stale data from the cache would help in this case.

I'd like to request "Cache-Control: max-age=3600, max-stale" and have a
stale result returned whenever the server goes 503. Currently this just
invalidates a precious (yet stale) cache.

As it is, I can do a "Cache-Control: only-if-cached" and try again in case
nothing is cached.

Original issue reported on code.google.com by [email protected] on 10 Aug 2008 at 5:05

FileCache saves images with corrupted newlines

1. Have httplib2 cache an moderately complex and/or large image off a
server that returns the right headers for caching. Use FileCache (by
passing a string path to the Http constructor).
2. Rerequest the image.
3. See traceback!

You expect to pull the image off of your hard drive. Instead there was junk.

This is fixed by changing the file read and write modes in the FileCache
class to "rb" and "wb" respectively.

Original issue reported on code.google.com by [email protected] on 11 Mar 2008 at 8:56

Using a timeout in the constructor always makes the socket fail

What steps will reproduce the problem?
1. using python 2.5.2 from python.org
2. http = httplib2.Http(timeout=N) where N is any value 
3. http.add_credentials(user, pass)
4. http.request(resource_uri,"PUT", body=resource_data)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.3-i386/egg/httplib2/__init__.py", line 1050,
in request
  File "build/bdist.macosx-10.3-i386/egg/httplib2/__init__.py", line 854,
in _request
  File "build/bdist.macosx-10.3-i386/egg/httplib2/__init__.py", line 823,
in _conn_request
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/httplib.py",
line 866, in request
    self._send_request(method, url, body, headers)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/httplib.py",
line 892, in _send_request
    self.send(body)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/httplib.py",
line 711, in send
    self.sock.sendall(str)
  File "<string>", line 1, in sendall
socket.error: (35, 'Resource temporarily unavailable')

What is the expected output? What do you see instead?

A response :)

What version of the product are you using? On what operating system?

On MacOS Tiger 10.4.11 / Intel

Please provide any additional information below.

Removing the timeout makes everything work, but the ability to make a hung
connection fail is critical.

Original issue reported on code.google.com by [email protected] on 18 Nov 2008 at 9:58

Http.Request() does not support iterated bodies

Related:
http://code.google.com/p/httplib2/issues/detail?id=25

Http objects do not support httplib's putrequest() and send(), which means
that iterative support can not even be easily added. (Httplib does not
support iterator file bodies, but it appears that it is possible to add it
with send()).

Thus, a significant number of parallel uploads, or a single large upload,
would consume all memory. Strangely, this seems to be a low priority for
most http libraries, and I believe urllib and urllib2 have a similar
limitation.

This has an impact in several key USE cases for this library:
1) server-based file uploader (i.e., S3)
2) server-based proxies
3) large file uploads (i.e., larger than RAM)

For now, the workaround seems to be to use raw httplib for PUTs and POSTs,
but I haven't tested to yet see if it supports multiple send() requests.

Original issue reported on code.google.com by [email protected] on 2 Dec 2008 at 7:07

  • Merged into: #5

Getting intermittant ServerNotFoundError errors

  File "page_load_test.py", line 48, in load_url
    response, content = http.request(url, 'GET', headers=headers)
  File "build/bdist.linux-i686/egg/httplib2/__init__.py", line 1050, in request
  File "build/bdist.linux-i686/egg/httplib2/__init__.py", line 854, in _request
  File "build/bdist.linux-i686/egg/httplib2/__init__.py", line 827, in
_conn_request
ServerNotFoundError: Unable to find the server at ubuntuforums.org

I'm attaching the file I'm trying to run.

Original issue reported on code.google.com by [email protected] on 18 Nov 2007 at 2:53

Attachments:

Make it possible to give nonstandard HTTP methods the same If-Match behavior as PUT

The Internet-Draft that defines PATCH
(http://tools.ietf.org/html/draft-dusseault-http-patch-11#section-2) says
that an ETag can be used as the value for If-Match when making a PATCH
request, just as with PUT. The Http.request() method sets If-Match for PUT
requests, but making it work for PATCH requests as well requires hacking
httplib2.

PATCH isn't an official HTTP method, so it's not a good idea to add support
for it to httplib2. But httplib2 is friendly towards nonstandard HTTP
methods, so it seems reasonable to make it easy to change this behavior by
subclassing. One solution is to move the list of methods out of request()
and into a class variable.

Original issue reported on code.google.com by [email protected] on 25 Aug 2008 at 10:12

Attachments:

Sockets left in CLOSE_WAIT after requests, eventually run out of file handles

What steps will reproduce the problem?
1. Configure Sam Ruby's Planet Venus to spider 1000+ feeds in an OPML file
2. Set spider_threads to about 12 or more
3. Run venus/spider.py

What is the expected output? What do you see instead?

The spidering run should complete without errors beyond problems in the
feeds themselves.  Instead, I start seeing "Too Many Files Open" errors
about 2/3 of the way through

What version of the product are you using? On what operating system?

SVN checkout r274 to replace what comes with Venus, on Mac OS X

Please provide any additional information below.

After running a large set of feeds through Planet Venus a few times, I
finally tried lsof when the Too Many Files Open errors started.  This
revealed almost every feed that had been polled so far in a CLOSE_WAIT
state.  So, I rummaged around in the code and found that if I inserted
conn.close() in a few spots in _conn_request(), that my problem was solved.
 Attached is a patch showing what I did.

But, what I wonder now is if these connections were left open for a reason
and if this patch breaks HTTP persistent connections?

Original issue reported on code.google.com by [email protected] on 2 Nov 2008 at 4:33

Attachments:

httplib2 performance

https://sourceforge.net/tracker/?func=detail&atid=105470&aid=508437&group_id=547
0

Also, from Tim Kientzle:

> Unfortunately, the workaround mentioned in that bug
> report isn't entirely safe. Because httplib instantiates
> the buffering layer (via socket.makefile()) per-request,
> it has to either disable buffering or risk over-running the next
> response on the wire. Disabling buffering means that you
> have a separate system call to read each byte of HTTP
> header, which is truly painful.

Original issue reported on code.google.com by [email protected] on 31 Jul 2007 at 1:13

email.Message.Message.items() is Set-Cookie hostile

From Ian Bicking:

httplib2 seems to be using email.Message.Message.items() for getting the
headers. I believe this function folds headers in a way that is
supposed to be valid for HTTP, but in practice does not produce valid
Set-Cookie headers. In paste.proxy I encountered this problem, and had
to do this to pipe accurate headers through:

for full_header in res.msg.headers:
header, value = full_header.split(':', 1)
value = value.strip()
headers_out.append((header, value))

There might also be a safe way to fold multiple Set-Cookie headers, but
the standard ways to fold headers don't work. Maybe parsing the cookie
headers and then reserializing would work; then you could use a dict.
Otherwise something like paste.util.multidict.MultiDict could still
support the headers (or wsgiref has another header dict-like object, I
believe).

Original issue reported on code.google.com by [email protected] on 31 Jul 2007 at 1:11

  • Merged into: #11

Try, except without a specific error gives problems

All try/excepts don't catch specific errors which is a _really_ bad 
practice.

When running a script it's not even possible to ctrl+c it or kill the 
program with a normal term signal, it really ought to be changed.

Original issue reported on code.google.com by Wolphie on 18 Aug 2007 at 2:54

_normalize_headers() does not convert values to string

Creating a header with an integer value, such as Keep-Alive or
Content-Length will result in a traceback similar to the following:


File '/usr/local/proxycache/httplib2/__init__.py', line 942 in request
  headers = _normalize_headers(headers)
File '/usr/local/proxycache/httplib2/__init__.py', line 194 in
_normalize_headers
  return dict([ (key.lower(), NORMALIZE_SPACE.sub(value, ' ').strip())  for
(key, value) in headers.iteritems()])
File '/usr/local/lib/python2.5/re.py', line 269 in _subx
  template = _compile_repl(template, pattern)
File '/usr/local/lib/python2.5/re.py', line 254 in _compile_repl
  p = sre_parse.parse_template(repl, pattern)
File '/usr/local/lib/python2.5/sre_parse.py', line 700 in parse_template
  s = Tokenizer(source)
File '/usr/local/lib/python2.5/sre_parse.py', line 187 in __init__
  self.__next()
File '/usr/local/lib/python2.5/sre_parse.py', line 189 in __next
  if self.index >= len(self.string):
TypeError: object of type 'int' has no len()

Original issue reported on code.google.com by [email protected] on 2 Dec 2008 at 6:59

httplib2 fails to fetch Google web history RSS feeds

httlib2 seems to have issues fetching Google's "web history" RSS feeds::

   >>> import httplib2
   >>> h = httplib2.Http()
   >>> h.add_credentials("jacob.kaplanmoss", MY_PASSWORD)
   >>> resp, body =
h.request("https://www.google.com/history/lookup?month=1&day=3&yr=2007&output=rs
s")
   Traceback (most recent call last):

      ...
   httplib.BadStatusLine

(Note that this doesn't happen with fetching plain-old HTML since that uses
GoogleLogin instead of HTTP Basic.)

The problem doesn't appear to be something that Google's doing since
urllib2 works fine::

    >>> import urllib2
    >>> auth = urllib2.HTTPBasicAuthHandler()
    >>> auth.add_password("Google Search History", "www.google.com",
"jacob.kaplanmoss", MY_PASSWORD)
    >>> opener = urllib2.build_opener(auth)
    >>> resp =
opener.open("http://www.google.com/history/lookup?month=1&day=3&yr=2007&output=r
ss")
    # ^^^ works fine

This is against r264 of httplib2. Python 2.5, OS X 10.5.

Original issue reported on code.google.com by [email protected] on 7 Jan 2008 at 6:11

non GET redirects are changed into GET

When receiving a 303 response + a Location:-header with a non-GET request
method (e.g. POST/PUT/DELETE), the request is changed into a GET and
redirected to the location defined in the Location:-header.

I would rather get an exception so this can be handled by the user instead
of  a transparent change to a GET. Or the possibility to indicate that the
method in the redirected request should not change.

Alternatively, this can be worked around by using the follow_redirects
attribute.

Original issue reported on code.google.com by [email protected] on 31 Aug 2007 at 9:16

No way to disable http compression.

There is currently no way to disable HTTP compression.

I am using httplib2 in a testing scenario, and one of those tests is to
check that a server supports http compression.

But httplib2 automatically adds "accept-encoding: gzip" to all outgoing
requests, and then auto-decompresses the response, removing the all
important "content-encoding: gzip" header. These are exactly the things I
need to test.

So in order to use httplib2 for this kind of testing, I have to comment out
the relevant bits of code. Which is not a huge problem, but now I have a
non-standard httplib2 module.

Original issue reported on code.google.com by [email protected] on 27 May 2008 at 10:35

Using urllib2 for a POST fail with basecamp

1.Working example with curl
2.Failing example with urllib2

"""
curl -v -H "Accept: application/xml" -H "Content-Type: 
application/xml" -u 
***:*** -L -d 
"<request><entry><project-id>***</project-id><person-id>***</person-id><date>200
80113</date><hours>1.0</hours><description>jabberbot</description></entry></requ
est>" 
http://electronlibre.projectpath.com/projects/1554720/time/save_entry"""


people_id = 911949
import urllib2
import base64
base64string = base64.encodestring('%s:%s' % ("***", "***"))
#headers = 
{'Accept': 'application/xml', 'Content-Type':'application/xml', 
"Authorization":"Basic %s" % 
base64string}
entry = 
str("<request><entry><project-id>***</project-id><person-id>***</person-id><date
>20080113</date><hours>1.0</hours><description>jabberbot</description></entry></
request>")

opener = urllib2.build_opener()
import urllib
#v = {'request':entry}
#entry = urllib.urlencode(v)
r = 
urllib2.Request('http://electronlibre.projectpath.com/time/save_entry', 
data=entry)
#r = urllib2.Request('http://127.0.0.1:8000/test/', data=entry)
r.add_header('Content-Type', 'application/xml')
r.add_header('Accept', 'application/xml')
#r.add_header('Content-length', len(entry)+2)
r.add_header('Authorization', 'Basic %s' % base64string)
try:
    print opener.open(r).read()
except urllib2.HTTPError, e:
    print e
    print "Request failure"

--------------------

The python fail because the data entry become amputed of these two last 
characters. If I had two space at the end of the entry string, It 
worked...

Can you reproduce it?

Original issue reported on code.google.com by [email protected] on 27 Mar 2008 at 3:41

HEAD Content-Length

HEAD responses are always returned with a content-length of zero, which is
wrong, and not helpful for some of the use cases for HEAD.

Original issue reported on code.google.com by [email protected] on 31 Jul 2007 at 1:12

Async support

Add the ability of httplib2 to operate async on sockets.


Original issue reported on code.google.com by [email protected] on 31 Jul 2007 at 1:15

Retrieving Yahoo OpenID page results in incomplete body entitity

>>> from httplib2 import Http
>>> http = Http()
>>> http.request('https://me.yahoo.com/christophermlenz')
({'status': '200', 'content-location': 'https://me.yahoo.com/christophermlenz', 
'transfer-
encoding': 'chunked', 'connection': 'close', 'date': 'Thu, 28 Feb 2008 10:19:53 
GMT', 'p3p': 
'policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI 
PSA PSD 
IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN 
COM NAV INT 
DEM CNT STA POL HEA PRE GOV"', 'content-type': 'text/html; charset=utf-8'}, 
'<!-- 
oid03.member.re3.yahoo.com uncompressed/chunked Thu Feb 28 02:19:53 PST 2008 
-->\n')

Note that the body only contains a trailing comment of the page. The URL does 
however contain 
quite a bit of HTML markup before that comment. Maybe something with the 
declared chunked 
encoding??

Tried with both the 0.4.0 release and trunk, and both Python 2.4 and 2.5.

Original issue reported on code.google.com by cmlenz on 28 Feb 2008 at 10:23

Slow performance due to Nagle algorithm (and solution)

Hi,

First of all, thanks for a great python module.

During some tests I made, I measured some very long delays in replies to
HTTP POST using httplib2.
It turns out the delays are caused by Nagle algorithm, and that performance
can be greatly improved by setting TCPNODELAY, which disables Nagle's
algorithm.
See
http://developers.slashdot.org/comments.pl?sid=174457&threshold=1&commentsort=0&
mode=thread&cid=14515105

for more details.

In a Linux environment, the extra delay is 40ms per request. For Windows
it's 200ms.

This delay can be eliminated with the following patch:

-------------------------------------------------------------
import socket

#
# Socket wrapper to enable socket.TCP_NODELAY
#
realsocket = socket.socket
def socketwrap(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0):
    sockobj = realsocket(family, type, proto)
    sockobj.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
    return sockobj

socket.socket = socketwrap
-------------------------------------------------------------

Attached is a small benchmark to demonstrate the improvement.
The results are:

httplib2 WITHOUT TCP_NODELAY: 100 runs in 4.085498 secs (24.476821
runs/sec, 40854.978561 microsecs/run)
httplib2 WITH TCP_NODELAY: 100 runs in 0.253862 secs (393.914953 runs/sec,
2538.619041 microsecs/run)


or in other words, a 94% performance improvement!

Note that the performance improvement will be noticed mainly in POST
requests because they are implemented with two separate socket writes.
Improvement for GET requests, with a single write, will be much smaller.

Thanks,
Ron

Original issue reported on code.google.com by [email protected] on 10 Jun 2008 at 12:58

Attachments:

Converted documentation (Sphinx)

I have attached documentation converted into format understood by the new
python documentation tool (Sphinx - http://sphinx.pocoo.org/)

The new format can come handy if httplib2 is to make into standard library.

Original issue reported on code.google.com by [email protected] on 4 May 2008 at 6:09

Attachments:

buggy

What steps will reproduce the problem?
1. visit a web site with httplib2 
2. which has the cookie content like "expires=Tue, 17-Jul-2007 07:22:55
GMT; path=/, domain=deleted; expires=Tue, 17-Jul-2007 07:22:55 GMT; path=/,
path=deleted; expires=Tue, 17-Jul-2007 07:22:55 GMT; path=/,
expires=deleted; expires=Tue, 17-Jul-2007 07:22:55 GMT; path=/', 'server':
'CWS/0.9'"
3. then I fail the access the web site with the cookie returned.

What is the expected output? What do you see instead?
proceed visiting the web site.
I see something like 

<br /> <b>Warning</b>: Cookie names can not contain any of the folllowing
'=,; \t\r\n\013\014' (HttpOnly?,JSESSIONID) in
<b>/www/xxxx/home/include/config/config.php</b> on line <b>190</b><br /> <br />


blablabla ...


What version of the product are you using? On what operating system?
httplib2-0.4.0 , python 2.5, windows xp

Please provide any additional information below.

it seems the cookie is not formatted like the http server needs ? can any
one help ?

regards, 
hui cai

Original issue reported on code.google.com by [email protected] on 16 Jul 2008 at 7:44

303 See Other after a POST doesn't clear the message body

What steps will reproduce the problem?
1. POST to a URL that will return a 303 redirect.

>>> (r, c) = httplib2.Http().request("...someurl...", method="POST", 
body="arg1=foo")
>>> r['status']
'400'
>>> r.previous['status']
'303'
>>> r.previous['location']
'http://localhost/'

2. When the 303 comes back, a new request, with method="GET" is generated.
3. The new GET request goes to the server, which dies with: 400 Bad Request

Because: GET requests cannot have content-length > 0.

The fix (in version 2.0.4.0-py2.5), is at httplib2/__init__.py:898

redirect_method = ((response.status == 303) and (method not in ["GET", 
"HEAD"])) and "GET" or method

should be:

if response.status == 303 and method not in ("GET","HEAD"):
  redirect_method = "GET"
  body = None
else:
  redirect_method = method

An edited __init__.py is attached.

Original issue reported on code.google.com by [email protected] on 7 Jan 2009 at 7:23

Attachments:

Gzip errors on broken pages

What steps will reproduce the problem?
1. Fetching the url
http://imaddicted.ca/ebooks/so-i-just-bought-the-foxit-eslick-reader/
2.
3.

What is the expected output? What do you see instead?
FailedToDecompressContent exception is raised instead of content returned.
The site has a WP Super Cache plugin installed, which breaks the gzipped
content by adding a HTML comment at the end. The patch attached solves that
by retrying fetch without using compression.

What version of the product are you using? On what operating system?
r276

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 9 Mar 2009 at 9:16

Attachments:

The cache can be become corrupt with bogus 301s

See here:

  http://intertwingly.net/blog/2007/11/05/Poisoned-Cache

Need some way to control when/if httplib2 caches a 301. 
Maybe track and allow the user to determine how many
days a 301 must be in place before caching it?

Original issue reported on code.google.com by [email protected] on 5 Nov 2007 at 4:02

Errors in instantiation of exceptions

What steps will reproduce the problem?
1. Just connect to an HTTPS server using MD5-sess

What is the expected output? What do you see instead?

It should fail because md5-sess is not supported by httplib2 but it fails
because UnimplementedDigestAuthOptionError and
UnimplementedHmacDigestAuthOptionError are subclasses of
HttpLib2ErrorWithResponse which has 3 required arguments. The exceptions
are instantiated with only one.


What version of the product are you using? On what operating system?

Ubuntu Linux 8.04 with Python 2.5, httplib2 0.4.0

Original issue reported on code.google.com by [email protected] on 16 Jun 2008 at 1:31

Cache-Control: only-if-cached incorrectly does request if item not in cache

See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.4

When passing 'Cache-Control: only-if-cached' via headers to httplib2
request, if the item is cached, it correctly returns immediately without
doing a new request.  However if the item is not cached, it passes through
the request, when it should immediately return with a 504.

Patch attached.

Original issue reported on code.google.com by [email protected] on 26 Oct 2007 at 8:23

Attachments:

Default file cache doesn't work on windows

In order to write binary data to a file on windows the 'wb' mode must be
used. The default flat file cache opens all files in text mode. Regrettable
text mode on windows translates the file corrupting things.

The same problems hold true for reading files as well.

The solution is to use the 'b' modes when doing file io. These modes have
no effect on other platforms (AFAIK)

Original issue reported on code.google.com by [email protected] on 6 Sep 2008 at 6:25

httplib2 asks for "compress" encoding that it can't handle

_decompress_content handles the content encodings "gzip" and "deflate". But
Http.request() sets Accept-Encoding to "compress, gzip". If a server
actually sent data encoded with "compress", httplib2 wouldn't decompress
it. And httplib never asks for "deflate".

This looks to be just a typo. Changing "compress" to "deflate" in
Http.request() should fix it.

Original issue reported on code.google.com by [email protected] on 27 Aug 2008 at 4:00

Force exception to status code and connection error

What steps will reproduce the problem?

1. Set force_exception_to_status_code to False
2. Try to connect to a closed port o to a non existant server


What is the expected output? What do you see instead?

The library converts the "Connection refused" socket error to a
HTTPException returning 400 which is definitely not. The error handling
should catch exceptions more specifically


What version of the product are you using? On what operating system?

I'm using httplib2 0.4.0 and python 2.4


Original issue reported on code.google.com by [email protected] on 23 Nov 2007 at 10:01

Allow HTTP digest auth against Apple's Calendar Server

Apple's Calendar Server uses HTTP digest auth, but doesn't set qop in the 
WWW-Authenticate 
header, and specifies algorithm=md5 in lowercase. This prevents httplib2 0.4.0 
from 
authenticating successfully.

This patch to httplib2/__init__.py fixes the problem:

         Authentication.__init__(self, credentials, host, request_uri, headers, response, content, http)
         challenge = _parse_www_authenticate(response, 'www-authenticate')
         self.challenge = challenge['digest']
-        qop = self.challenge.get('qop')
+        qop = self.challenge.get('qop', 'auth')
         self.challenge['qop'] = ('auth' in [x.strip() for x in qop.split()]) and 'auth' or None
         if self.challenge['qop'] is None:
             raise UnimplementedDigestAuthOptionError( _("Unsupported value for qop: %s." % qop))
-        self.challenge['algorithm'] = self.challenge.get('algorithm', 'MD5')
+        self.challenge['algorithm'] = self.challenge.get('algorithm', 
'MD5').upper()
         if self.challenge['algorithm'] != 'MD5':
             raise UnimplementedDigestAuthOptionError( _("Unsupported value for algorithm: %s." % 
self.challenge['algorithm']))
         self.A1 = "".join([self.credentials[0], ":", self.challenge['realm'], ":", self.credentials[1]]) 

Original issue reported on code.google.com by [email protected] on 23 Mar 2008 at 7:39

slow dns lookups (socket.getaddrinfo) corrected by socket.AF_INET option instead of 0

What steps will reproduce the problem?
1. http post

What is the expected output? What do you see instead?
very long (seconds) dns lookups in socket.getaddrinfo call at
__init__.py line 690


What version of the product are you using? On what operating system?
fedora core 7, python-2.5-15.fc7, httplib2 rev 259 (0.4.0)

I made the change to the arguments as described here
http://mail.python.org/pipermail/python-list/2003-December/240479.html

and it went much faster. I'm not familiar with all the issues here however.

thanks, great interface BTW.

Original issue reported on code.google.com by [email protected] on 30 Oct 2008 at 3:53

Proxy support not working with squid proxy

I am not able to use proxy support while httplib and urrlib2 works fine.

I'm using the newest version of httplib2.

Here's the code that I use:
    proxy = {
             'host':'http://144.16.192.245',
             'port':8000}
    httplib2.debuglevel=4
    conn = httplib2.Http(proxy_info =
httplib2.ProxyInfo(myhttp.socks.PROXY_TYPE_HTTP, proxy['host'], proxy['port']))
    # ...snip...
    response,content = conn.request(url, headers = headers1)    
    return response, content


And this is the output I see:
INFO:404trainer:Retrieving http://www.example.org/
Traceback (most recent call last):


  File "/home/anirudhs/workspace/iviz/src/test.py", line 71, in <module>
    response, content = http_request("http://www.example.org/")
  File "/home/anirudhs/workspace/iviz/src/test.py", line 32, in http_request
    response,content = conn.request(url, headers = headers1)    
  File "/home/anirudhs/workspace/iviz/src/httplib2/__init__.py", line 1071,
in request
    (response, content) = self._request(conn, authority, uri, request_uri,
method, body, headers, redirections, cachekey)
  File "/home/anirudhs/workspace/iviz/src/httplib2/__init__.py", line 863,
in _request
    (response, content) = self._conn_request(conn, request_uri, method,
body, headers)
  File "/home/anirudhs/workspace/iviz/src/httplib2/__init__.py", line 836,
in _conn_request
    raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
httplib2.ServerNotFoundError: Unable to find the server at www.example.org


Please delete this issue if it's not a bug. I just need proxy support as I
do not have a direct connection.

Original issue reported on code.google.com by [email protected] on 26 Oct 2008 at 3:02

a couple of deprecated warnings

using python 2.6

I am seeing:

/usr/lib/python2.6/site-packages/httplib2-0.4.0-py2.6.egg/httplib2/__init__.py:2
9:
DeprecationWarning: the md5 module is deprecated; use hashlib instead
/usr/lib/python2.6/site-packages/httplib2-0.4.0-py2.6.egg/httplib2/__init__.py:4
4:
DeprecationWarning: the sha module is deprecated; use the hashlib module
instead

Original issue reported on code.google.com by pjkeane on 4 Mar 2009 at 9:22

problem while closing connection on openbsd and maybe bsd*

What steps will reproduce the problem?
1. set Connection: close in header
2. get a url on some server like couchdb server in this case
(http://couchdb.org)
3. try another GET


What is the expected output? What do you see instead?
I would get a page on step 3but instead I get ('54', 'Reset by peer') error.

What version of the product are you using? On what operating system?
last stable version of httplib2 on OpenBSD


Find a patch that solve this problem.


Original issue reported on code.google.com by [email protected] on 5 May 2008 at 12:50

Attachments:

email.message_from_string slows down cache retrieval for large documents

When large documents are retrieved from the cache, a lot of time is spent
parsing the cached response. (to the point where it is a lot faster if the
document is NOT in the cache)

I *think* this is unnecessary because as far as I can see, this is only
needed to get the headers. This means that email.message_from_string should
probably be called with only the first part of the cached response. (maybe
this also makes the change from revision 266 unnecessary?)

The following change seems to work:

    if cached_value:
        try:
            info, content = cached_value.split('\r\n\r\n', 1)
        except IndexError:
            self.cache.delete(cachekey)
            cachekey = None
            cached_value = None
        info = email.message_from_string(info)



Original issue reported on code.google.com by [email protected] on 23 Jul 2008 at 12:36

Vary header

The cache appears not to support the Vary header - doesn't this omission
mean that httplib2 is not a correct HTTP 1.1 implementation at all? It
violates the MUST NOT @
http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.6

(This is particularly odd as the xml.com article cited on the front page
specifically mentions 'Vary' as being one of the important considerations
for a caching http client...)

Original issue reported on code.google.com by [email protected] on 9 Dec 2008 at 3:20

Needs to catch socket.error(54, 'Connection reset by peer')

What steps will reproduce the problem?
1. Write code that sends a request to a webserver, sleeps 45 seconds or so,
and then does it again.  I was doing it against a couchdb server; may have
slightly different behaviors with a more standard http server.

What is the expected output? What do you see instead?

- This error should be caught and the request resubmitted.  Instead, the
error is not caught.

What version of the product are you using? On what operating system?

0.4.0, on Mac and Linux.

Please provide any additional information below.

I will attach a patch that works for me.

Original issue reported on code.google.com by [email protected] on 26 Sep 2008 at 9:34

Attachments:

Support for iterating over very large responses

In httplib, one can read the response body iteratively so he needs only a
fixed amount of memory for very large responses. For example, in an WSGI
app one can write:

    ...
    size = 8192
    with closing(conn):
        res = conn.getresponse()
        content = iter(lambda: res.read(size), '')
        start_response('200 OK', [])
        return content

It would be nice to have such a possibility in httplib2.

Original issue reported on code.google.com by [email protected] on 8 May 2008 at 2:04

  • Merged into: #5

DeprecationWarning with python 2.6

What steps will reproduce the problem?
1. start python.exe (version 2.6 or 2.6 stackless)
2. import httplib2  

It gives your DeprecationWarning, because md5 and sha should be changed to 
hashlib.
In python 3.0 there is no more md5 or sha.

>>> import httplib2
httplib2\__init__.py:29: DeprecationWarning: the md5 module is deprecated; 
use hashlib instead
  import md5
httplib2\__init__.py:44: DeprecationWarning: the sha module is deprecated; 
use the hashlib module instead
  import sha


Original issue reported on code.google.com by [email protected] on 19 Dec 2008 at 4:10

Content-Location not set after redirect with HEAD requests

<http://bitworking.org/projects/httplib2/ref/response-objects.html> states that:

  The Response object also populates the header content-location,
  that contains the URI that was ultimately requested. This is useful
  if redirects were encountered, you can determine the ultimate URI
  that the request was sent to.

However, for HEAD requests this doesn't seem to work:

  >>> from httplib2 import Http
  >>> http = Http()
  >>> resp, body = http.request('http://cmlenz.net/', method='HEAD')
  >>> resp['content-location']
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  KeyError: 'content-location'
  >>> resp.previous
  {'status': '301', 'content-location': 'http://cmlenz.net/', 'location': 'http://www.cmlenz.net/'}

So it looks like the ultimate URL currently needs to be pulled out of the 
'Location' header of the 
'previous' response (if there was one).

Original issue reported on code.google.com by cmlenz on 28 Feb 2008 at 8:12

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.