Mailinglist Archive: opensuse-commit (1214 mails)

< Previous Next >
commit python-httplib2 for openSUSE:Factory
  • From: root@xxxxxxxxxxxxxxx (h_root)
  • Date: Tue, 04 Aug 2009 23:12:21 +0200
  • Message-id: <20090804211221.B241861B4@xxxxxxxxxxxxxxx>

Hello community,

here is the log from the commit of package python-httplib2 for openSUSE:Factory
checked in at Tue Aug 4 23:12:21 CEST 2009.


--------
--- python-httplib2/python-httplib2.changes 2008-09-09 21:12:06.000000000
+0200
+++ python-httplib2/python-httplib2.changes 2009-08-04 13:11:49.000000000
+0200
@@ -1,0 +2,14 @@
+Tue Aug 4 10:51:26 UTC 2009 - cstender@xxxxxxxxxx
+
+- updated to version 0.5.0
+ * Fixed the following bugs:
+ #12 - Cache-Control: only-if-cached incorrectly does request if
+ item not in cache
+ #39 - Deprecation warnings in Python 2.6
+ #54 - Http.request fails accesing Google account via http proxy
+ #56 - Block on response.read() for HEAD requests.
+ #57 - Timeout ignore for Python 2.6
+ #58 - Fixed parsing of Cache-Control: header to make it more
+ robust
+
+-------------------------------------------------------------------

calling whatdependson for head-i586


Old:
----
httplib2-0.4.0.tar.gz

New:
----
httplib2-0.5.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-httplib2.spec ++++++
--- /var/tmp/diff_new_pack.pfnaJe/_old 2009-08-04 23:11:47.000000000 +0200
+++ /var/tmp/diff_new_pack.pfnaJe/_new 2009-08-04 23:11:47.000000000 +0200
@@ -1,7 +1,7 @@
#
-# spec file for package python-httplib2 (Version 0.4.0)
+# spec file for package python-httplib2 (Version 0.5.0)
#
-# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -21,10 +21,10 @@
Name: python-httplib2
BuildRequires: python-devel
Summary: A Python HTTP library
-Version: 0.4.0
+Version: 0.5.0
Release: 1
Source0: httplib2-%{version}.tar.gz
-License: X11/MIT
+License: MIT License (or similar)
Group: Development/Libraries/Python
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Url: http://bitworking.org/projects/httplib2/
@@ -48,7 +48,6 @@
CFLAGS="$RPM_OPT_FLAGS" python setup.py build

%install
-rm -rf $RPM_BUILD_ROOT
python setup.py install --prefix=%{_prefix} --root=$RPM_BUILD_ROOT
--record-rpm=INSTALLED_FILES

%clean

++++++ httplib2-0.4.0.tar.gz -> httplib2-0.5.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/httplib2-0.4.0/PKG-INFO new/httplib2-0.5.0/PKG-INFO
--- old/httplib2-0.4.0/PKG-INFO 2007-10-23 17:27:36.000000000 +0200
+++ new/httplib2-0.5.0/PKG-INFO 2009-07-28 17:22:49.000000000 +0200
@@ -1,12 +1,12 @@
Metadata-Version: 1.0
Name: httplib2
-Version: 0.4.0
+Version: 0.5.0
Summary: A comprehensive HTTP client library.
-Home-page: http://bitworking.org/projects/httplib2/
+Home-page: http://code.google.com/p/httplib2/
Author: Joe Gregorio
Author-email: joe@xxxxxxxxxxxxxx
License: MIT
-Download-URL:
http://bitworking.org/projects/httplib2/dist/httplib2-0.4.0.tar.gz
+Download-URL: http://httplib2.googlecode.com/files/httplib2-0.5.0.tar.gz
Description:

A comprehensive HTTP client library, ``httplib2`` supports many
features left out of other HTTP libraries.
@@ -58,5 +58,6 @@
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/httplib2-0.4.0/httplib2/__init__.py
new/httplib2-0.5.0/httplib2/__init__.py
--- old/httplib2-0.4.0/httplib2/__init__.py 2007-10-23 17:25:46.000000000
+0200
+++ new/httplib2-0.5.0/httplib2/__init__.py 2009-07-28 14:22:33.000000000
+0200
@@ -22,14 +22,14 @@
"Sam Ruby",
"Louis Nyffenegger"]
__license__ = "MIT"
-__version__ = "$Rev: 259 $"
+__version__ = "$Rev$"

import re
import sys
-import md5
import email
import email.Utils
import email.Message
+import email.FeedParser
import StringIO
import gzip
import zlib
@@ -41,7 +41,14 @@
import calendar
import time
import random
-import sha
+# remove depracated warning in python2.6
+try:
+ from hashlib import sha1 as _sha, md5 as _md5
+except ImportError:
+ import sha
+ import md5
+ _sha = sha.new
+ _md5 = md5.new
import hmac
from gettext import gettext as _
import socket
@@ -51,12 +58,27 @@
except ImportError:
socks = None

+# Build the appropriate socket wrapper for ssl
+try:
+ import ssl # python 2.6
+ _ssl_wrap_socket = ssl.wrap_socket
+except ImportError:
+ def _ssl_wrap_socket(sock, key_file, cert_file):
+ ssl_sock = socket.ssl(sock, key_file, cert_file)
+ return httplib.FakeSocket(sock, ssl_sock)
+
+
if sys.version_info >= (2,3):
from iri2uri import iri2uri
else:
def iri2uri(uri):
return uri

+def has_timeout(timeout): # python 2.6
+ if hasattr(socket, '_GLOBAL_DEFAULT_TIMEOUT'):
+ return (timeout is not None and timeout is not
socket._GLOBAL_DEFAULT_TIMEOUT)
+ return (timeout is not None)
+
__all__ = ['Http', 'Response', 'ProxyInfo', 'HttpLib2Error',
'RedirectMissingLocation', 'RedirectLimit', 'FailedToDecompressContent',
'UnimplementedDigestAuthOptionError',
'UnimplementedHmacDigestAuthOptionError',
@@ -66,6 +88,7 @@
# The httplib debug level, set to a non-zero value to get debug output
debuglevel = 0

+
# Python 2.3 support
if sys.version_info < (2,4):
def sorted(seq):
@@ -180,7 +203,7 @@
pass
if isinstance(filename,unicode):
filename=filename.encode('utf-8')
- filemd5 = md5.new(filename).hexdigest()
+ filemd5 = _md5(filename).hexdigest()
filename = re_url_scheme.sub("", filename)
filename = re_slash.sub(",", filename)

@@ -197,8 +220,8 @@
retval = {}
if headers.has_key('cache-control'):
parts = headers['cache-control'].split(',')
- parts_with_args = [tuple([x.strip() for x in part.split("=")]) for
part in parts if -1 != part.find("=")]
- parts_wo_args = [(name.strip(), 1) for name in parts if -1 ==
name.find("=")]
+ parts_with_args = [tuple([x.strip().lower() for x in part.split("=",
1)]) for part in parts if -1 != part.find("=")]
+ parts_wo_args = [(name.strip().lower(), 1) for name in parts if -1 ==
name.find("=")]
retval = dict(parts_with_args + parts_wo_args)
return retval

@@ -327,6 +350,8 @@
if encoding == 'deflate':
content = zlib.decompress(content)
response['content-length'] = str(len(content))
+ # Record the historical presence of the encoding in a way the
won't interfere.
+ response['-content-encoding'] = response['content-encoding']
del response['content-encoding']
except IOError:
content = ""
@@ -359,11 +384,11 @@
cache.set(cachekey, text)

def _cnonce():
- dig = md5.new("%s:%s" % (time.ctime(), ["0123456789"[random.randrange(0,
9)] for i in range(20)])).hexdigest()
+ dig = _md5("%s:%s" % (time.ctime(), ["0123456789"[random.randrange(0, 9)]
for i in range(20)])).hexdigest()
return dig[:16]

def _wsse_username_token(cnonce, iso_now, password):
- return base64.encodestring(sha.new("%s%s%s" % (cnonce, iso_now,
password)).digest()).strip()
+ return base64.encodestring(_sha("%s%s%s" % (cnonce, iso_now,
password)).digest()).strip()


# For credentials we need two things, first
@@ -425,11 +450,11 @@
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]])
@@ -437,7 +462,7 @@

def request(self, method, request_uri, headers, content, cnonce = None):
"""Modify the request headers"""
- H = lambda x: md5.new(x).hexdigest()
+ H = lambda x: _md5(x).hexdigest()
KD = lambda s, d: H("%s:%s" % (s, d))
A2 = "".join([method, ":", request_uri])
self.challenge['cnonce'] = cnonce or _cnonce()
@@ -497,13 +522,13 @@
if self.challenge['pw-algorithm'] not in ['SHA-1', 'MD5']:
raise UnimplementedHmacDigestAuthOptionError( _("Unsupported value
for pw-algorithm: %s." % self.challenge['pw-algorithm']))
if self.challenge['algorithm'] == 'HMAC-MD5':
- self.hashmod = md5
+ self.hashmod = _md5
else:
- self.hashmod = sha
+ self.hashmod = _sha
if self.challenge['pw-algorithm'] == 'MD5':
- self.pwhashmod = md5
+ self.pwhashmod = _md5
else:
- self.pwhashmod = sha
+ self.pwhashmod = _sha
self.key = "".join([self.credentials[0], ":",
self.pwhashmod.new("".join([self.credentials[1],
self.challenge['salt']])).hexdigest().lower(),
":", self.challenge['realm']
@@ -600,9 +625,6 @@

AUTH_SCHEME_ORDER = ["hmacdigest", "googlelogin", "digest", "wsse", "basic"]

-def _md5(s):
- return
-
class FileCache(object):
"""Uses a local directory as a store for cached files.
Not really safe to use if multiple threads or processes are going to
@@ -618,7 +640,7 @@
retval = None
cacheFullPath = os.path.join(self.cache, self.safe(key))
try:
- f = file(cacheFullPath, "r")
+ f = file(cacheFullPath, "rb")
retval = f.read()
f.close()
except IOError:
@@ -627,7 +649,7 @@

def set(self, key, value):
cacheFullPath = os.path.join(self.cache, self.safe(key))
- f = file(cacheFullPath, "w")
+ f = file(cacheFullPath, "wb")
f.write(value)
f.close()

@@ -697,11 +719,12 @@
else:
self.sock = socket.socket(af, socktype, proto)
# Different from httplib: support timeouts.
- if self.timeout is not None:
+ if has_timeout(self.timeout):
self.sock.settimeout(self.timeout)
# End of difference from httplib.
if self.debuglevel > 0:
print "connect: (%s, %s)" % (self.host, self.port)
+
self.sock.connect(sa)
except socket.error, msg:
if self.debuglevel > 0:
@@ -719,24 +742,24 @@

def __init__(self, host, port=None, key_file=None, cert_file=None,
strict=None, timeout=None, proxy_info=None):
- self.timeout = timeout
- self.proxy_info = proxy_info
httplib.HTTPSConnection.__init__(self, host, port=port,
key_file=key_file,
cert_file=cert_file, strict=strict)
+ self.timeout = timeout
+ self.proxy_info = proxy_info

def connect(self):
"Connect to a host on a given (SSL) port."

if self.proxy_info and self.proxy_info.isgood():
- self.sock.setproxy(*self.proxy_info.astuple())
+ sock = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM)
sock.setproxy(*self.proxy_info.astuple())
else:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- if self.timeout is not None:
+
+ if has_timeout(self.timeout):
sock.settimeout(self.timeout)
sock.connect((self.host, self.port))
- ssl = socket.ssl(sock, self.key_file, self.cert_file)
- self.sock = httplib.FakeSocket(sock, ssl)
+ self.sock =_ssl_wrap_socket(sock, self.key_file, self.cert_file)



@@ -780,6 +803,10 @@

# If set to False then no redirects are followed, even safe ones.
self.follow_redirects = True
+
+ # Which HTTP methods do we apply optimistic concurrency to, i.e.
+ # which methods get an "if-match:" etag header added to them.
+ self.optimistic_concurrency_methods = ["PUT"]

# If 'follow_redirects' is True, and this is set to True then
# all redirecs are followed, including unsafe ones.
@@ -821,11 +848,16 @@
for i in range(2):
try:
conn.request(method, request_uri, body, headers)
- response = conn.getresponse()
except socket.gaierror:
conn.close()
raise ServerNotFoundError("Unable to find the server at %s" %
conn.host)
- except httplib.HTTPException, e:
+ except (socket.error, httplib.HTTPException):
+ # Just because the server closed the connection doesn't
apparently mean
+ # that the server didn't send a response.
+ pass
+ try:
+ response = conn.getresponse()
+ except (socket.error, httplib.HTTPException):
if i == 0:
conn.close()
conn.connect()
@@ -833,12 +865,13 @@
else:
raise
else:
- content = response.read()
+ content = ""
+ if method != "HEAD":
+ content = response.read()
response = Response(response)
if method != "HEAD":
content = _decompressContent(response, content)
-
- break;
+ break
return (response, content)


@@ -947,6 +980,10 @@
uri = iri2uri(uri)

(scheme, authority, request_uri, defrag_uri) = urlnorm(uri)
+ domain_port = authority.split(":")[0:2]
+ if len(domain_port) == 2 and domain_port[1] == '443' and scheme ==
'http':
+ scheme = 'https'
+ authority = domain_port[0]

conn_key = scheme+":"+authority
if conn_key in self.connections:
@@ -962,8 +999,8 @@
conn = self.connections[conn_key] =
connection_type(authority, timeout=self.timeout, proxy_info=self.proxy_info)
conn.set_debuglevel(debuglevel)

- if method in ["GET", "HEAD"] and 'range' not in headers:
- headers['accept-encoding'] = 'compress, gzip'
+ if method in ["GET", "HEAD"] and 'range' not in headers and
'accept-encoding' not in headers:
+ headers['accept-encoding'] = 'deflate, gzip'

info = email.Message.Message()
cached_value = None
@@ -971,9 +1008,17 @@
cachekey = defrag_uri
cached_value = self.cache.get(cachekey)
if cached_value:
- info = email.message_from_string(cached_value)
+ # info = email.message_from_string(cached_value)
+ #
+ # Need to replace the line above with the kludge below
+ # to fix the non-existent bug not fixed in this
+ # bug report:
http://mail.python.org/pipermail/python-bugs-list/2005-September/030289.html
try:
- content = cached_value.split('\r\n\r\n', 1)[1]
+ info, content = cached_value.split('\r\n\r\n', 1)
+ feedparser = email.FeedParser.FeedParser()
+ feedparser.feed(info)
+ info = feedparser.close()
+ feedparser._parse = None
except IndexError:
self.cache.delete(cachekey)
cachekey = None
@@ -981,7 +1026,7 @@
else:
cachekey = None

- if method in ["PUT"] and self.cache and info.has_key('etag') and
not self.ignore_etag and 'if-match' not in headers:
+ if method in self.optimistic_concurrency_methods and self.cache
and info.has_key('etag') and not self.ignore_etag and 'if-match' not in headers:
# http://www.w3.org/1999/04/Editing/
headers['if-match'] = info['etag']

@@ -1047,7 +1092,13 @@
self.cache.delete(cachekey)
content = new_content
else:
- (response, content) = self._request(conn, authority, uri,
request_uri, method, body, headers, redirections, cachekey)
+ cc = _parse_cache_control(headers)
+ if cc.has_key('only-if-cached'):
+ info['status'] = '504'
+ response = Response(info)
+ content = ""
+ else:
+ (response, content) = self._request(conn, authority, uri,
request_uri, method, body, headers, redirections, cachekey)
except Exception, e:
if self.force_exception_to_status_code:
if isinstance(e, HttpLib2ErrorWithResponse):
@@ -1101,7 +1152,7 @@
# an httplib.HTTPResponse object.
if isinstance(info, httplib.HTTPResponse):
for key, value in info.getheaders():
- self[key] = value
+ self[key.lower()] = value
self.status = info.status
self['status'] = str(self.status)
self.reason = info.reason
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/httplib2-0.4.0/setup.py new/httplib2-0.5.0/setup.py
--- old/httplib2-0.4.0/setup.py 2007-10-23 17:25:46.000000000 +0200
+++ new/httplib2-0.5.0/setup.py 2009-07-28 17:01:19.000000000 +0200
@@ -1,11 +1,11 @@
from distutils.core import setup
-VERSION = '0.4.0'
+VERSION = '0.5.0'
setup(name='httplib2',
version=VERSION,
author='Joe Gregorio',
author_email='joe@xxxxxxxxxxxxxx',
- url='http://bitworking.org/projects/httplib2/',
-
download_url='http://bitworking.org/projects/httplib2/dist/httplib2-%s.tar.gz'
% VERSION,
+ url='http://code.google.com/p/httplib2/',
+ download_url='http://httplib2.googlecode.com/files/httplib2-%s.tar.gz'
% VERSION,
description='A comprehensive HTTP client library.',
license='MIT',
long_description="""
@@ -60,6 +60,7 @@
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
+ 'Programming Language :: Python :: 3',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries',
],


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Remember to have fun...

--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread