Compare commits

...

42 Commits

Author SHA1 Message Date
Kenneth Reitz
8c90c610cd v0.7.6
Fixes #237
2011-11-07 14:20:32 -05:00
Kenneth Reitz
1a85e110b8 Merge branch 'develop' of github.com:kennethreitz/requests into develop 2011-11-07 14:18:20 -05:00
Kenneth Reitz
12fa108ede add query data to digest path 2011-11-07 14:18:05 -05:00
Kenneth Reitz
9c3ca6e740 The Washington Post 2011-11-07 10:42:10 -05:00
Kenneth Reitz
12ada03548 Merge pull request #244 from neogenix/patch-1
Updated your 2001, to 2011... unless you went back in time ;)
2011-11-06 19:58:34 -08:00
Patrick
daa4fbf4e2 Updated your 2001, to 2011... unless you went back in time ;) 2011-11-06 21:57:47 -06:00
Kenneth Reitz
7ce305fa89 french post 2011-11-06 13:25:34 -05:00
Kenneth Reitz
04cdd0f2e7 daikon 2011-11-06 13:24:23 -05:00
Kenneth Reitz
33ee732082 steal @shazow's contribute paragraph 2011-11-04 23:57:43 -04:00
Kenneth Reitz
cf36d8c753 changes! 2011-11-04 23:32:15 -04:00
Kenneth Reitz
bd562a7ab3 Merge branch 'develop' of https://github.com/davidfischer/requests into develop 2011-11-04 23:28:21 -04:00
Kenneth Reitz
72c8163aee davidfischer 2011-11-04 23:27:50 -04:00
Kenneth Reitz
2bae57e0a6 v0.7.5 2011-11-04 23:26:31 -04:00
Kenneth Reitz
f7968b6797 r.content is None of there's an invalid response.
Fixes #236
2011-11-04 23:24:38 -04:00
Kenneth Reitz
4cae63a297 take out weinre 2011-11-04 23:00:38 -04:00
Kenneth Reitz
628325ae90 Official™ mobile-friendly 2011-11-04 22:58:43 -04:00
Kenneth Reitz
b3e2410f44 mobile auto width 2011-11-04 22:15:54 -04:00
Kenneth Reitz
a02189a8e9 hide rtd on mobile docs 2011-11-04 22:14:12 -04:00
Kenneth Reitz
d343fda7f0 Merge remote-tracking branch 'origin/develop' into develop 2011-11-04 21:59:16 -04:00
Kenneth Reitz
f9bcf7c611 revert 2011-11-04 21:59:12 -04:00
Kenneth Reitz
23b0535a0d Update AUTHORS 2011-11-04 11:51:38 -03:00
Kenneth Reitz
32c7cbf1ad Merge pull request #238 from brutasse/docs-typo
Fixed a broken link in the docs
2011-11-04 07:51:07 -07:00
Bruno Renié
8fe6f8c618 Fixed a broken link in the docs 2011-11-04 15:49:29 +01:00
Kenneth Reitz
80c55f5767 python-rexster 2011-11-03 19:03:11 -03:00
David Fischer
3efd5dbab4 A cleaner and more complete fix for auth/redirects 2011-11-03 08:05:55 -07:00
David Fischer
eaf1264879 Fixes an issue with auth and redirects 2011-11-02 23:29:31 -07:00
Kenneth Reitz
f5592ceb48 Merge remote-tracking branch 'origin/develop' into develop 2011-11-02 20:39:15 -04:00
Kenneth Reitz
e32840f631 fix request docs 2011-11-02 20:39:06 -04:00
Kenneth Reitz
4596c02339 Merge pull request #234 from anatomyofashane/develop
ch ch chcnages
2011-10-31 18:53:07 -07:00
Shane McDonald
4fcf14e124 ch ch chcnages
via @kennethreitz
2011-10-31 21:50:57 -04:00
Kenneth Reitz
797301a63b Merge pull request #233 from anatomyofashane/develop
Update docs/_themes/kr/static/flasky.css_t
2011-10-31 18:26:52 -07:00
anatomyofashane
3615cbc9df Update docs/_themes/kr/static/flasky.css_t 2011-10-31 22:24:59 -03:00
Kenneth Reitz
e43b438729 test fix 2011-10-26 18:42:58 -04:00
Kenneth Reitz
8836c4b12a history 2011-10-26 18:38:32 -04:00
Kenneth Reitz
3a4f6ba8b3 v0.7.4 2011-10-26 18:36:14 -04:00
Kenneth Reitz
6ac1e02691 hooks fix #227 2011-10-26 18:35:01 -04:00
Kenneth Reitz
6140fac6aa Default Accept header, a la curl 2011-10-25 16:10:49 -04:00
Kenneth Reitz
73ed950e70 simplify 2011-10-24 20:55:35 -04:00
Kenneth Reitz
6ef5094be6 Merge remote-tracking branch 'origin/develop' into develop 2011-10-24 20:55:01 -04:00
Kenneth Reitz
077758f713 Merge pull request #224 from stoey/84e89429
Syntax error for Python 2.5
2011-10-24 17:54:05 -07:00
Kenneth Reitz
c108c5300f No mo' HttpError 2011-10-23 17:18:46 -04:00
Dan Head
84e89429f0 Syntax fix for Python 2.5 2011-10-14 22:24:42 +00:00
17 changed files with 118 additions and 24 deletions

View File

@@ -46,4 +46,7 @@ Patches and Suggestions
- Josselin Jacquard
- Travis N. Vaught
- Fredrik Möllerstrand
- Daniel Hengeveld
- Daniel Hengeveld
- Dan Head
- Bruno Renié
- David Fischer

View File

@@ -1,6 +1,22 @@
History
-------
0.7.6 (2011-11-07)
++++++++++++++++++
* Digest authentication bugfix (attach query data to path)
0.7.5 (2011-11-04)
++++++++++++++++++
* Response.content = None if there was an invalid repsonse.
* Redirection auth handling.
0.7.4 (2011-10-26)
++++++++++++++++++
* Sesion Hooks fix.
0.7.3 (2011-10-23)
++++++++++++++++++

View File

@@ -93,8 +93,10 @@ But, you really shouldn't do that.
Contribute
----------
If you'd like to contribute, simply fork `the repository`_, commit your changes to the **develop** branch (or branch off of it), and send a pull request. Make sure you add yourself to AUTHORS_.
#. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. There is a Contributor Friendly tag for issues that should be ideal for people who are not very familiar with the codebase yet.
#. Fork `the repository`_ on Github to start making your changes to the **develop** branch (or branch off of it).
#. Write a test which shows that the bug was fixed or that the feature works as expected.
#. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS_.
.. _`the repository`: http://github.com/kennethreitz/requests
.. _AUTHORS: http://github.com/kennethreitz/requests/blob/master/AUTHORS

View File

@@ -2,18 +2,19 @@
{%- block extrahead %}
{{ super() }}
{% if theme_touch_icon %}
<link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}" />
<link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}" />
{% endif %}
<link media="only screen and (max-device-width: 480px)" href="{{
pathto('_static/small_flask.css', 1) }}" type= "text/css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
{% endblock %}
{%- block relbar2 %}{% endblock %}
{%- block footer %}
<div class="footer">
&copy; Copyright {{ copyright }}.
</div>
<a href="https://github.com/kennethreitz/requests">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" />
<a href="https://github.com/kennethreitz/requests" class="github">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" class="github"/>
</a>
<script type="text/javascript">

View File

@@ -393,6 +393,11 @@ a:hover tt {
display: none;
}
div.document {
width: 100%;
}
div.documentwrapper {
margin-left: 0;
margin-top: 0;
@@ -415,6 +420,10 @@ a:hover tt {
width: auto;
}
.footer {
width: auto;
}
.bodywrapper {
margin: 0;
}
@@ -423,7 +432,9 @@ a:hover tt {
width: auto;
}
.github {
display: none;
}
}

View File

@@ -68,3 +68,23 @@ div.body {
min-height: 0;
padding: 0;
}
.rtd_doc_footer {
display: none;
}
.document {
width: auto;
}
.footer {
width: auto;
}
.footer {
width: auto;
}
.github {
display: none;
}

View File

@@ -7,6 +7,8 @@ Modules
- `fullerene <https://github.com/bitprophet/fullerene>`_, a Graphite Dashboard.
- `urbanairship-python <https://github.com/benjaminws/urbanairship-python>`_, a fork of the Urban Airship API wrapper.
- `WhitespaceBot <https://github.com/Gunio/WhitespaceBot/>`_, a project that automatically forks repos, strips trailing whitespace, and sends a pull request.
- `python-rexster <https://github.com/CulturePlex/python-rexster>`_, Rexter client that provides a simple interface for graph databases.
- `daikon <https://github.com/neogenix/daikon>`_, a CLI for ElasticSearch.
Articles & Talks
================
@@ -16,6 +18,7 @@ Articles & Talks
- `Issac Kelly's 'Consuming Web APIs' talk <http://issackelly.github.com/Consuming-Web-APIs-with-Python-Talk/slides/slides.html>`_
- `Blog post about Requests via Yum <http://arunsag.wordpress.com/2011/08/17/new-package-python-requests-http-for-humans/>`_
- `Russian blog post introducing Requests <http://habrahabr.ru/blogs/python/126262/>`_
- `French blog post introducing Requests <http://www.nicosphere.net/requests-urllib2-de-python-simplifie-2432/>`_
Integrations

View File

@@ -39,7 +39,7 @@ all the hard work and crazy hacks for you.
Testimonials
------------
`Twitter, Inc <http://twitter.com>`_,
`The Washington Post <http://www.washingtonpost.com/>`_, `Twitter, Inc <http://twitter.com>`_,
a U.S. Federal Institution,
NIH,
`Readability <http://readability.com>`_, and

View File

@@ -164,4 +164,4 @@ Requests supports it!::
-----------------------
Ready for more? Check out the advanced_ section.
Ready for more? Check out the :ref:`advanced <advanced>` section.

View File

@@ -15,15 +15,15 @@ requests
"""
__title__ = 'requests'
__version__ = '0.7.3'
__build__ = 0x000703
__version__ = '0.7.6'
__build__ = 0x000706
__author__ = 'Kenneth Reitz'
__license__ = 'ISC'
__copyright__ = 'Copyright 2011 Kenneth Reitz'
from . import utils
from .models import HTTPError, Request, Response
from .models import Request, Response
from .api import request, get, head, post, patch, put, delete
from .sessions import session
from .status_codes import codes

View File

@@ -29,6 +29,23 @@ def request(method, url,
hooks=None,
return_response=True,
config=None):
"""Constructs and sends a :class:`Request <Request>`.
Returns :class:`Response <Response>` object.
:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.
:param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
:param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.
:param auth: (optional) Auth typle to enable Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) Float describing the timeout of the request.
:param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param return_response: (optional) If False, an un-sent Request object will returned.
:param config: (optional) A configuration dictionary.
"""
s = session()
return s.request(

View File

@@ -32,7 +32,10 @@ def patched(f):
"""Patches a given API function to not send."""
def wrapped(*args, **kwargs):
return f(*args, return_response=False, **kwargs)
kwargs['return_response'] = False
return f(*args, **kwargs)
return wrapped

View File

@@ -67,7 +67,8 @@ def http_digest(r, username, password):
# XXX not implemented yet
entdig = None
path = urlparse(r.request.url).path
p_parsed = urlparse(r.request.url)
path = p_parsed.path + p_parsed.query
A1 = "%s:%s:%s" % (username, realm, password)
A2 = "%s:%s" % (r.request.method, path)

View File

@@ -26,6 +26,7 @@ defaults = dict()
defaults['base_headers'] = {
'User-Agent': 'python-requests/%s' % __version__,
'Accept-Encoding': ', '.join(('identity', 'deflate', 'compress', 'gzip')),
'Accept': '*/*'
}
defaults['proxies'] = {}

View File

@@ -12,21 +12,22 @@ import urllib2
import socket
import zlib
from urllib2 import HTTPError
from urlparse import urlparse, urlunparse, urljoin
from datetime import datetime
from .auth import dispatch as auth_dispatch
from .hooks import dispatch_hook
from .structures import CaseInsensitiveDict
from .packages.poster.encode import multipart_encode
from .packages.poster.streaminghttp import register_openers, get_handlers
from .utils import (dict_from_cookiejar, get_unicode_from_response, stream_decode_response_unicode, decode_gzip, stream_decode_gzip)
from .status_codes import codes
from .exceptions import Timeout, URLRequired, TooManyRedirects
from .monkeys import Request as _Request
from .monkeys import HTTPRedirectHandler
from .utils import (
dict_from_cookiejar, get_unicode_from_response,
stream_decode_response_unicode, decode_gzip, stream_decode_gzip)
from .auth import dispatch as auth_dispatch
REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)
@@ -95,6 +96,7 @@ class Request(object):
self.response = Response()
#: Authentication tuple to attach to :class:`Request <Request>`.
self._auth = auth
self.auth = auth_dispatch(auth)
#: CookieJar to attach to :class:`Request <Request>`.
@@ -236,7 +238,7 @@ class Request(object):
method=method,
# data=self.data,
# params=self.params,
auth=self.auth,
auth=self._auth,
cookies=self.cookies,
redirect=True,
config=self.config
@@ -495,7 +497,11 @@ class Response(object):
'already consumed')
# Read the contents.
self._content = self.raw.read()
try:
self._content = self.raw.read()
except AttributeError:
return None
# Decode GZip'd content.
if 'gzip' in self.headers.get('content-encoding', ''):

View File

@@ -51,7 +51,9 @@ def merge_kwargs(local_kwarg, default_kwarg):
class Session(object):
"""A Requests session."""
__attrs__ = ['headers', 'cookies', 'auth', 'timeout', 'proxies', 'hooks', 'params', 'config']
__attrs__ = [
'headers', 'cookies', 'auth', 'timeout', 'proxies', 'hooks',
'params', 'config']
def __init__(self,
@@ -62,7 +64,8 @@ class Session(object):
proxies=None,
hooks=None,
params=None,
config=None):
config=None,
keep_alive=True):
self.headers = headers or {}
self.cookies = cookies or {}
@@ -72,6 +75,7 @@ class Session(object):
self.hooks = hooks or {}
self.params = params or {}
self.config = config or {}
self.keep_alive = keep_alive
for (k, v) in defaults.items():
self.config.setdefault(k, v)
@@ -157,8 +161,9 @@ class Session(object):
args[attr] = merge_kwargs(local_val, session_val)
# Arguments manipulation hook.
args = dispatch_hook('args', hooks, args)
args = dispatch_hook('args', args['hooks'], args)
r = Request(**args)
@@ -169,7 +174,6 @@ class Session(object):
# Send the HTTP Request.
r.send()
return r.response

View File

@@ -10,6 +10,7 @@ import unittest
import requests
import envoy
from urllib2 import HTTPError
try:
import omnijson as json
@@ -239,7 +240,7 @@ class RequestsTestSuite(unittest.TestCase):
def test_status_raising(self):
r = requests.get(httpbin('status', '404'))
self.assertRaises(requests.HTTPError, r.raise_for_status)
self.assertRaises(HTTPError, r.raise_for_status)
r = requests.get(httpbin('status', '200'))
self.assertFalse(r.error)
@@ -528,6 +529,11 @@ class RequestsTestSuite(unittest.TestCase):
assert params3['b'] in r3.content
assert params3['c'] in r3.content
def test_invalid_content(self):
r = requests.get('http://somedomainthatclearlydoesntexistg.com')
assert r.content == None
if __name__ == '__main__':
unittest.main()