diff --git a/HISTORY.rst b/HISTORY.rst
index 1fa26b7f..969ad843 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -9,6 +9,8 @@ Release History
**Bugfixes**
- Don't use redirect_cache if allow_redirects=False
+- When passed objects that throw exceptions from ``tell()``, send them via
+ chunked transfer encoding instead of failing.
2.9.1 (2015-12-21)
++++++++++++++++++
diff --git a/Makefile b/Makefile
index 60b5e000..a8289712 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,8 @@ chardet:
publish:
python setup.py register
python setup.py sdist upload
- python setup.py bdist_wheel upload
+ python setup.py bdist_wheel --universal upload
+ rm -fr build dist .egg requests.egg-info
docs-init:
diff --git a/README.rst b/README.rst
index 80f2edf7..9fe548d2 100644
--- a/README.rst
+++ b/README.rst
@@ -74,6 +74,7 @@ To install Requests, simply:
.. code-block:: bash
$ pip install requests
+ ✨🍰✨
Satisfaction, guaranteed.
diff --git a/docs/MANIFEST.in b/docs/MANIFEST.in
deleted file mode 100644
index fb1021bf..00000000
--- a/docs/MANIFEST.in
+++ /dev/null
@@ -1 +0,0 @@
-include HISTORY.rst README.rst LICENSE
\ No newline at end of file
diff --git a/docs/Makefile b/docs/Makefile
index 946ba445..08a2acf6 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -7,6 +7,11 @@ SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
@@ -14,8 +19,7 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
-
+.PHONY: help
help:
@echo "Please use \`make ' where is one of"
@echo " html to make standalone HTML files"
@@ -25,53 +29,66 @@ help:
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
+ @echo " applehelp to make an Apple Help Book"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " xml to make Docutils-native XML files"
+ @echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
+ @echo " coverage to run coverage check of the documentation (if enabled)"
+.PHONY: clean
clean:
- -rm -rf $(BUILDDIR)/*
+ rm -rf $(BUILDDIR)/*
+.PHONY: html
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+.PHONY: dirhtml
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+.PHONY: singlehtml
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+.PHONY: pickle
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
+.PHONY: json
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
+.PHONY: htmlhelp
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
+.PHONY: qthelp
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@@ -81,6 +98,16 @@ qthelp:
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Requests.qhc"
+.PHONY: applehelp
+applehelp:
+ $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
+ @echo
+ @echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
+ @echo "N.B. You won't be able to view it unless you put it in" \
+ "~/Library/Documentation/Help or install it in your application" \
+ "bundle."
+
+.PHONY: devhelp
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@@ -90,11 +117,13 @@ devhelp:
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Requests"
@echo "# devhelp"
+.PHONY: epub
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+.PHONY: latex
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@@ -102,22 +131,33 @@ latex:
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
+.PHONY: latexpdf
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
- make -C $(BUILDDIR)/latex all-pdf
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+.PHONY: latexpdfja
+latexpdfja:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through platex and dvipdfmx..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+.PHONY: text
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
+.PHONY: man
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+.PHONY: texinfo
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@@ -125,29 +165,52 @@ texinfo:
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
+.PHONY: info
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+.PHONY: gettext
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+.PHONY: changes
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
+.PHONY: linkcheck
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
+.PHONY: doctest
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
+
+.PHONY: coverage
+coverage:
+ $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
+ @echo "Testing of coverage in the sources finished, look at the " \
+ "results in $(BUILDDIR)/coverage/python.txt."
+
+.PHONY: xml
+xml:
+ $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+ @echo
+ @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+.PHONY: pseudoxml
+pseudoxml:
+ $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+ @echo
+ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
diff --git a/docs/_static/konami.js b/docs/_static/konami.js
new file mode 100644
index 00000000..d72cf9df
--- /dev/null
+++ b/docs/_static/konami.js
@@ -0,0 +1,116 @@
+/*
+ * Konami-JS ~
+ * :: Now with support for touch events and multiple instances for
+ * :: those situations that call for multiple easter eggs!
+ * Code: http://konami-js.googlecode.com/
+ * Examples: http://www.snaptortoise.com/konami-js
+ * Copyright (c) 2009 George Mandis (georgemandis.com, snaptortoise.com)
+ * Version: 1.4.2 (9/2/2013)
+ * Licensed under the MIT License (http://opensource.org/licenses/MIT)
+ * Tested in: Safari 4+, Google Chrome 4+, Firefox 3+, IE7+, Mobile Safari 2.2.1 and Dolphin Browser
+ */
+
+var Konami = function (callback) {
+ var konami = {
+ addEvent: function (obj, type, fn, ref_obj) {
+ if (obj.addEventListener)
+ obj.addEventListener(type, fn, false);
+ else if (obj.attachEvent) {
+ // IE
+ obj["e" + type + fn] = fn;
+ obj[type + fn] = function () {
+ obj["e" + type + fn](window.event, ref_obj);
+ };
+ obj.attachEvent("on" + type, obj[type + fn]);
+ }
+ },
+ input: "",
+ pattern: "38384040373937396665",
+ load: function (link) {
+ this.addEvent(document, "keydown", function (e, ref_obj) {
+ if (ref_obj) konami = ref_obj; // IE
+ konami.input += e ? e.keyCode : event.keyCode;
+ if (konami.input.length > konami.pattern.length)
+ konami.input = konami.input.substr((konami.input.length - konami.pattern.length));
+ if (konami.input == konami.pattern) {
+ konami.code(link);
+ konami.input = "";
+ e.preventDefault();
+ return false;
+ }
+ }, this);
+ this.iphone.load(link);
+ },
+ code: function (link) {
+ window.location = link
+ },
+ iphone: {
+ start_x: 0,
+ start_y: 0,
+ stop_x: 0,
+ stop_y: 0,
+ tapTolerance: 8,
+ capture: false,
+ orig_keys: "",
+ keys: ["UP", "UP", "DOWN", "DOWN", "LEFT", "RIGHT", "LEFT", "RIGHT", "TAP", "TAP"],
+ code: function (link) {
+ konami.code(link);
+ },
+ touchCapture: function(evt) {
+ konami.iphone.start_x = evt.changedTouches[0].pageX;
+ konami.iphone.start_y = evt.changedTouches[0].pageY;
+ konami.iphone.capture = true;
+ },
+ load: function (link) {
+ this.orig_keys = this.keys;
+ konami.addEvent(document, "touchmove", function (e) {
+ if (e.touches.length == 1 && konami.iphone.capture == true) {
+ var touch = e.touches[0];
+ konami.iphone.stop_x = touch.pageX;
+ konami.iphone.stop_y = touch.pageY;
+ konami.iphone.check_direction();
+ }
+ });
+ konami.addEvent(document, "touchend", function (evt) {
+ konami.touchCapture(evt);
+ konami.iphone.check_direction(link);
+ }, false);
+ konami.addEvent(document, "touchstart", function (evt) {
+ konami.touchCapture(evt);
+ });
+ },
+ check_direction: function (link) {
+ var x_magnitude = Math.abs(this.start_x - this.stop_x);
+ var y_magnitude = Math.abs(this.start_y - this.stop_y);
+ var hasMoved = (x_magnitude > this.tapTolerance || y_magnitude > this.tapTolerance);
+ var result;
+ if (this.capture === true && hasMoved) {
+ this.capture = false;
+ var x = ((this.start_x - this.stop_x) < 0) ? "RIGHT" : "LEFT";
+ var y = ((this.start_y - this.stop_y) < 0) ? "DOWN" : "UP";
+ var result = (x_magnitude > y_magnitude) ? x : y;
+ }
+ else if (this.capture === false && !hasMoved) {
+ result = (this.tap == true) ? "TAP" : result;
+ result = "TAP";
+ }
+ if (result) {
+ if (result == this.keys[0]) this.keys = this.keys.slice(1, this.keys.length);
+ else this.keys = this.orig_keys;
+ }
+ if (this.keys.length == 0) {
+ this.keys = this.orig_keys;
+ this.code(link);
+ }
+ }
+ }
+ }
+
+ typeof callback === "string" && konami.load(callback);
+ if (typeof callback === "function") {
+ konami.code = callback;
+ konami.load();
+ }
+
+ return konami;
+};
diff --git a/docs/_templates/hacks.html b/docs/_templates/hacks.html
new file mode 100644
index 00000000..f9fc96cb
--- /dev/null
+++ b/docs/_templates/hacks.html
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html
deleted file mode 100644
index 3f435497..00000000
--- a/docs/_templates/layout.html
+++ /dev/null
@@ -1,86 +0,0 @@
-{%- extends "basic/layout.html" %}
-{%- block extrahead %}
-
- {{ super() }}
-
- {% if theme_touch_icon %}
-
- {% endif %}
-
-
-
-
-
-{% endblock %}
-{%- block relbar2 %}{% endblock %}
-{%- block footer %}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-{%- endblock %}
diff --git a/docs/_templates/sidebarintro.html b/docs/_templates/sidebarintro.html
index d2cbfe9d..7dbd74c8 100644
--- a/docs/_templates/sidebarintro.html
+++ b/docs/_templates/sidebarintro.html
@@ -14,30 +14,30 @@
human beings.
-
-
- Buy Requests Pro
-
-
-
-Get Updates
+Stay Informed
Receive updates on new releases and upcoming projects.
-Subscribe to Newsletter
+
+
-Translations
+Join Mailing List .
+
+Other Projects
+
+More Kenneth Reitz projects:
+
Useful Links
+
+
+Translations
+
+
+
diff --git a/docs/_templates/sidebarlogo.html b/docs/_templates/sidebarlogo.html
index 928cd2fd..1e295f81 100644
--- a/docs/_templates/sidebarlogo.html
+++ b/docs/_templates/sidebarlogo.html
@@ -14,13 +14,40 @@
development release.
-
- Buy Requests Pro
-
-
-Get Updates
+Stay Informed
Receive updates on new releases and upcoming projects.
-Subscribe to Newsletter
+Join Mailing List .
+
+
+
+
+
+Other Projects
+
+More Kenneth Reitz projects:
+
+Translations
+
+
+
diff --git a/docs/api.rst b/docs/api.rst
index b257f5ca..59b05232 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -25,9 +25,30 @@ They all return an instance of the :class:`Response ` object.
.. autofunction:: patch
.. autofunction:: delete
+Exceptions
+----------
+
+.. autoexception:: requests.RequestException
+.. autoexception:: requests.ConnectionError
+.. autoexception:: requests.HTTPError
+.. autoexception:: requests.URLRequired
+.. autoexception:: requests.TooManyRedirects
+.. autoexception:: requests.ConnectTimeout
+.. autoexception:: requests.ReadTimeout
+.. autoexception:: requests.Timeout
+
+
+Request Sessions
+----------------
+
+.. _sessionapi:
+
+.. autoclass:: Session
+ :inherited-members:
+
Lower-Level Classes
-~~~~~~~~~~~~~~~~~~~
+-------------------
.. autoclass:: requests.Request
:inherited-members:
@@ -35,10 +56,11 @@ Lower-Level Classes
.. autoclass:: Response
:inherited-members:
-Request Sessions
-----------------
-.. autoclass:: Session
+Lower-Lower-Level Classes
+-------------------------
+
+.. autoclass:: requests.PreparedRequest
:inherited-members:
.. autoclass:: requests.adapters.HTTPAdapter
@@ -52,39 +74,20 @@ Authentication
.. autoclass:: requests.auth.HTTPProxyAuth
.. autoclass:: requests.auth.HTTPDigestAuth
-Exceptions
-~~~~~~~~~~
-
-.. autoexception:: requests.exceptions.RequestException
-.. autoexception:: requests.exceptions.ConnectionError
-.. autoexception:: requests.exceptions.HTTPError
-.. autoexception:: requests.exceptions.URLRequired
-.. autoexception:: requests.exceptions.TooManyRedirects
-.. autoexception:: requests.exceptions.ConnectTimeout
-.. autoexception:: requests.exceptions.ReadTimeout
-.. autoexception:: requests.exceptions.Timeout
-Status Code Lookup
-~~~~~~~~~~~~~~~~~~
+Encodings
+---------
-.. autofunction:: requests.codes
+.. autofunction:: requests.utils.get_encodings_from_content
+.. autofunction:: requests.utils.get_encoding_from_headers
+.. autofunction:: requests.utils.get_unicode_from_response
-::
-
- >>> requests.codes['temporary_redirect']
- 307
-
- >>> requests.codes.teapot
- 418
-
- >>> requests.codes['\o/']
- 200
.. _api-cookies:
Cookies
-~~~~~~~
+-------
.. autofunction:: requests.utils.dict_from_cookiejar
.. autofunction:: requests.utils.cookiejar_from_dict
@@ -97,33 +100,23 @@ Cookies
:inherited-members:
-Encodings
-~~~~~~~~~
-.. autofunction:: requests.utils.get_encodings_from_content
-.. autofunction:: requests.utils.get_encoding_from_headers
-.. autofunction:: requests.utils.get_unicode_from_response
+Status Code Lookup
+------------------
+.. autoclass:: requests.codes
-Classes
-~~~~~~~
+::
-.. autoclass:: requests.Response
- :inherited-members:
+ >>> requests.codes['temporary_redirect']
+ 307
-.. autoclass:: requests.Request
- :inherited-members:
+ >>> requests.codes.teapot
+ 418
-.. autoclass:: requests.PreparedRequest
- :inherited-members:
+ >>> requests.codes['\o/']
+ 200
-.. _sessionapi:
-
-.. autoclass:: requests.Session
- :inherited-members:
-
-.. autoclass:: requests.adapters.HTTPAdapter
- :inherited-members:
Migrating to 1.x
diff --git a/docs/conf.py b/docs/conf.py
index a84469db..00e4261c 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
#
# Requests documentation build configuration file, created by
-# sphinx-quickstart on Sun Feb 13 23:54:25 2011.
+# sphinx-quickstart on Fri Feb 19 00:05:47 2016.
#
-# This file is execfile()d with the current directory set to its containing dir.
+# This file is execfile()d with the current directory set to its
+# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
@@ -11,34 +12,43 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys, os
+import sys
+import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# Insert Requests' path into the system.
sys.path.insert(0, os.path.abspath('..'))
+sys.path.insert(0, os.path.abspath('_themes'))
+
import requests
from requests import __version__
-import alabaster
-# -- General configuration -----------------------------------------------------
+# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
- 'alabaster'
+ 'sphinx.ext.todo',
+ 'sphinx.ext.viewcode',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
-# The suffix of source filenames.
+# The suffix(es) of source filenames.
+# You can specify multiple suffix as a list of string:
+# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The encoding of source files.
@@ -50,6 +60,7 @@ master_doc = 'index'
# General information about the project.
project = u'Requests'
copyright = u'2016. A Kenneth Reitz Project'
+author = u'Kenneth Reitz'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -58,11 +69,14 @@ copyright = u'2016. A tag referring to it. The value of this option must be the
@@ -181,23 +208,45 @@ html_show_sphinx = False
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
+# Language to be used for generating the HTML full-text search index.
+# Sphinx supports the following languages:
+# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
+# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
+#html_search_language = 'en'
+
+# A dictionary with options for the search language support, empty by default.
+# Now only 'ja' uses this config value
+#html_search_options = {'type': 'default'}
+
+# The name of a javascript file (relative to the configuration directory) that
+# implements a search results scorer. If empty, the default will be used.
+#html_search_scorer = 'scorer.js'
+
# Output file base name for HTML help builder.
htmlhelp_basename = 'Requestsdoc'
+# -- Options for LaTeX output ---------------------------------------------
-# -- Options for LaTeX output --------------------------------------------------
-
-# The paper size ('letter' or 'a4').
-#latex_paper_size = 'letter'
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
-#latex_font_size = '10pt'
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+
+# Latex figure (float) alignment
+#'figure_align': 'htbp',
+}
# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
latex_documents = [
- ('index', 'Requests.tex', u'Requests Documentation',
- u'Kenneth Reitz', 'manual'),
+ (master_doc, 'Requests.tex', u'Requests Documentation',
+ u'Kenneth Reitz', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -214,9 +263,6 @@ latex_documents = [
# If true, show URL addresses after external links.
#latex_show_urls = False
-# Additional stuff for the LaTeX preamble.
-#latex_preamble = ''
-
# Documents to append as an appendix to all manuals.
#latex_appendices = []
@@ -224,33 +270,110 @@ latex_documents = [
#latex_domain_indices = True
-# -- Options for manual page output --------------------------------------------
+# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
- ('index', 'requests', u'Requests Documentation',
- [u'Kenneth Reitz'], 1)
+ (master_doc, 'requests', u'Requests Documentation',
+ [author], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
-# -- Options for Texinfo output ------------------------------------------------
+
+# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- ('index', 'Requests', u'Requests Documentation', u'Kenneth Reitz',
- 'Requests', 'One line description of project.', 'Miscellaneous'),
+ (master_doc, 'Requests', u'Requests Documentation',
+ author, 'Requests', 'One line description of project.',
+ 'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
-texinfo_appendices = []
+#texinfo_appendices = []
-sys.path.append(os.path.abspath('_themes'))
-html_theme_path =[alabaster.get_path()]
-html_theme = 'alabaster'
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
+
+
+# -- Options for Epub output ----------------------------------------------
+
+# Bibliographic Dublin Core info.
+epub_title = project
+epub_author = author
+epub_publisher = author
+epub_copyright = copyright
+
+# The basename for the epub file. It defaults to the project name.
+#epub_basename = project
+
+# The HTML theme for the epub output. Since the default themes are not
+# optimized for small screen space, using the same theme for HTML and epub
+# output is usually not wise. This defaults to 'epub', a theme designed to save
+# visual space.
+#epub_theme = 'epub'
+
+# The language of the text. It defaults to the language option
+# or 'en' if the language is not set.
+#epub_language = ''
+
+# The scheme of the identifier. Typical schemes are ISBN or URL.
+#epub_scheme = ''
+
+# The unique identifier of the text. This can be a ISBN number
+# or the project homepage.
+#epub_identifier = ''
+
+# A unique identification for the text.
+#epub_uid = ''
+
+# A tuple containing the cover image and cover page html template filenames.
+#epub_cover = ()
+
+# A sequence of (type, uri, title) tuples for the guide element of content.opf.
+#epub_guide = ()
+
+# HTML files that should be inserted before the pages created by sphinx.
+# The format is a list of tuples containing the path and title.
+#epub_pre_files = []
+
+# HTML files that should be inserted after the pages created by sphinx.
+# The format is a list of tuples containing the path and title.
+#epub_post_files = []
+
+# A list of files that should not be packed into the epub file.
+epub_exclude_files = ['search.html']
+
+# The depth of the table of contents in toc.ncx.
+#epub_tocdepth = 3
+
+# Allow duplicate toc entries.
+#epub_tocdup = True
+
+# Choose between 'default' and 'includehidden'.
+#epub_tocscope = 'default'
+
+# Fix unsupported image types using the Pillow.
+#epub_fix_images = False
+
+# Scale large images.
+#epub_max_image_width = 0
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#epub_show_urls = 'inline'
+
+# If false, no index is generated.
+#epub_use_index = True
intersphinx_mapping = {'urllib3': ('http://urllib3.readthedocs.org/en/latest', None)}
diff --git a/docs/dev/contributing.rst b/docs/dev/contributing.rst
index 075d042a..93181dad 100644
--- a/docs/dev/contributing.rst
+++ b/docs/dev/contributing.rst
@@ -3,37 +3,40 @@
Contributor's Guide
===================
-If you're reading this you're probably interested in contributing to
-Requests. First, We'd like to say: thank you! Open source projects
-live-and-die based on the support they receive from others, and the fact that
-you're even considering supporting Requests is very generous of
-you.
+If you're reading this, you're probably interested in contributing to Requests.
+Thank you very much! Open source projects live-and-die based on the support
+they receive from others, and the fact that you're even considering
+contributing to the Requests project is *very* generous of you.
-This document lays out guidelines and advice for contributing to Requests.
-If you're thinking of contributing, start by reading this thoroughly and
-getting a feel for how contributing to the project works. If you have any
+This document lays out guidelines and advice for contributing to this project.
+If you're thinking of contributing, please start by reading this document and
+getting a feel for how contributing to this project works. If you have any
questions, feel free to reach out to either `Ian Cordasco`_ or `Cory Benfield`_,
the primary maintainers.
+.. _Ian Cordasco: http://www.coglib.com/~icordasc/
+.. _Cory Benfield: https://lukasa.co.uk/about
+
+If you have non-technical feedback, philosophical ponderings, crazy ideas, or
+other general thoughts about Requests or its position within the Python
+ecosystem, the BDFL, `Kenneth Reitz`_, would love to hear from you.
+
The guide is split into sections based on the type of contribution you're
thinking of making, with a section that covers general guidelines for all
contributors.
-.. _Ian Cordasco: http://www.coglib.com/~icordasc/
-.. _Cory Benfield: https://lukasa.co.uk/about
-
-
-All Contributions
------------------
+.. _Kenneth Reitz: mailto:me@kennethreitz.org
Be Cordial
-~~~~~~~~~~
+----------
-**Be cordial or be on your way.**
+ **Be cordial or be on your way**. *—Kenneth Reitz*
Requests has one very important rule governing all forms of contribution,
including reporting bugs or requesting features. This golden rule is
-`be cordial or be on your way`_. **All contributions are welcome**, as long as
+"`be cordial or be on your way`_".
+
+**All contributions are welcome**, as long as
everyone involved is treated with respect.
.. _be cordial or be on your way: http://kennethreitz.org/be-cordial-or-be-on-your-way/
@@ -41,7 +44,7 @@ everyone involved is treated with respect.
.. _early-feedback:
Get Early Feedback
-~~~~~~~~~~~~~~~~~~
+------------------
If you are contributing, do not feel the need to sit on your contribution until
it is perfectly polished and complete. It helps everyone involved for you to
@@ -51,22 +54,23 @@ getting that contribution accepted, and can save you from putting a lot of work
into a contribution that is not suitable for the project.
Contribution Suitability
-~~~~~~~~~~~~~~~~~~~~~~~~
+------------------------
-The project maintainer has the last word on whether or not a contribution is
-suitable for Requests. All contributions will be considered, but from time
-to time contributions will be rejected because they do not suit the project.
+Our project maintainers have the last word on whether or not a contribution is
+suitable for Requests. All contributions will be considered carefully, but from
+time to time, contributions will be rejected because they do not suit the
+current goals or needs of the project.
-If your contribution is rejected, don't despair! So long as you followed these
-guidelines, you'll have a much better chance of getting your next contribution
-accepted.
+If your contribution is rejected, don't despair! As long as you followed these
+guidelines, you will have a much better chance of getting your next
+contribution accepted.
Code Contributions
------------------
-Steps
-~~~~~
+Steps for Submitting Code
+~~~~~~~~~~~~~~~~~~~~~~~~~
When contributing code, you'll want to follow this checklist:
@@ -104,6 +108,56 @@ asking for help.
Please also check the :ref:`early-feedback` section.
+Kenneth Reitz's Code Style™
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The Requests codebase uses the `PEP 8`_ code style.
+
+In addition to the standards outlined in PEP 8, we have a few guidelines:
+
+- Line-length can exceed 79 characters, to 100, when convenient.
+- Line-length can exceed 100 characters, when doing otherwise would be *terribly* inconvenient.
+- Always use single-quoted strings (e.g. ``'#flatearth'``), unless a single-quote occurs within the string.
+
+Additionally, one of the styles that PEP8 recommends for `line continuations`_
+completely lacks all sense of taste, and is not to be permitted within
+the Requests codebase::
+
+ # Aligned with opening delimiter.
+ foo = long_function_name(var_one, var_two,
+ var_three, var_four)
+
+No. Just don't. Please.
+
+Docstrings are to follow the following syntaxes::
+
+ def the_earth_is_flat():
+ """NASA divided up the seas into thirty-three degrees."""
+ pass
+
+::
+
+ def fibonacci_spiral_tool():
+ """With my feet upon the ground I lose myself / between the sounds
+ and open wide to suck it in. / I feel it move across my skin. / I'm
+ reaching up and reaching out. / I'm reaching for the random or
+ whatever will bewilder me. / Whatever will bewilder me. / And
+ following our will and wind we may just go where no one's been. /
+ We'll ride the spiral to the end and may just go where no one's
+ been.
+
+ Spiral out. Keep going...
+ """
+ pass
+
+All functions, methods, and classes are to contain docstrings. Object data
+model methods (e.g. ``__repr__``) are typically the exception to this rule.
+
+Thanks for helping to make the world a better place!
+
+.. _PEP 8: http://pep8.org
+.. _line continuations: https://www.python.org/dev/peps/pep-0008/#indentation
+
Documentation Contributions
---------------------------
@@ -112,9 +166,12 @@ the ``docs/`` directory of the codebase. They're written in
`reStructuredText`_, and use `Sphinx`_ to generate the full suite of
documentation.
-When contributing documentation, please attempt to follow the style of the
+When contributing documentation, please do your best to follow the style of the
documentation files. This means a soft-limit of 79 characters wide in your text
-files and a semi-formal prose style.
+files and a semi-formal, yet friendly and approachable, prose style.
+
+When presenting Python code, use single-quoted strings (``'hello'`` instead of
+``"hello"``).
.. _reStructuredText: http://docutils.sourceforge.net/rst.html
.. _Sphinx: http://sphinx-doc.org/index.html
@@ -136,10 +193,14 @@ of other contributors, and should be avoided as much as possible.
Feature Requests
----------------
-Requests is in a perpetual feature freeze. The maintainers believe that
-requests contains every major feature currently required by the vast majority
-of users.
+Requests is in a perpetual feature freeze, only the BDFL can add or approve of
+new features. The maintainers believe that Requests is a feature-complete
+piece of software at this time.
+
+One of the most important skills to have while maintaining a largely-used
+open source project is learning the ability to say "no" to suggested changes,
+while keeping an open ear and mind.
If you believe there is a feature missing, feel free to raise a feature
request, but please do be aware that the overwhelming likelihood is that your
-feature request will not be accepted.
+feature request will not be accepted.
\ No newline at end of file
diff --git a/docs/index.rst b/docs/index.rst
index 0df56107..5eb643e1 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -38,8 +38,8 @@ URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling
are 100% automatic, powered by `urllib3 `_,
which is embedded within Requests.
-Testimonials
-------------
+User Testimonials
+-----------------
Her Majesty's Government, Amazon, Google, Twilio, Runscope, Mozilla, Heroku,
PayPal, NPR, Obama for America, Transifex, Native Instruments, The Washington
@@ -65,8 +65,8 @@ Institutions that prefer to be unnamed claim to use Requests internally.
Requests is one of the most downloaded Python packages of all time, pulling in
over 7,000,000 downloads every month. All the cool kids are doing it!
-Feature Support
----------------
+Supported Features
+------------------
Requests is ready for today's web.
@@ -90,8 +90,8 @@ Requests is ready for today's web.
Requests supports Python 2.6 — 3.5, and runs great on PyPy.
-User Guide
-----------
+The User Guide
+--------------
This part of the documentation, which is mostly prose, begins with some
background information about Requests, then focuses on step-by-step
@@ -107,8 +107,8 @@ instructions for getting the most out of Requests.
user/authentication
-Community Guide
------------------
+The Community Guide
+-------------------
This part of the documentation, which is mostly prose, details the
Requests ecosystem and community.
@@ -124,10 +124,10 @@ Requests ecosystem and community.
community/updates
community/release-process
-API Documentation
------------------
+The API Documentation / Guide
+-----------------------------
-If you are looking for information on a specific function, class or method,
+If you are looking for information on a specific function, class, or method,
this part of the documentation is for you.
.. toctree::
@@ -136,16 +136,19 @@ this part of the documentation is for you.
api
-Contributor Guide
------------------
+The Contributor Guide
+---------------------
If you want to contribute to the project, this part of the documentation is for
you.
.. toctree::
- :maxdepth: 1
+ :maxdepth: 3
dev/contributing
dev/philosophy
dev/todo
dev/authors
+
+There are no more guides. You are now guideless.
+Good luck.
diff --git a/docs/make.bat b/docs/make.bat
index 4441160c..9eaf9b88 100644
--- a/docs/make.bat
+++ b/docs/make.bat
@@ -1,190 +1,263 @@
-@ECHO OFF
-
-REM Command file for Sphinx documentation
-
-if "%SPHINXBUILD%" == "" (
- set SPHINXBUILD=sphinx-build
-)
-set BUILDDIR=_build
-set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
-set I18NSPHINXOPTS=%SPHINXOPTS% .
-if NOT "%PAPER%" == "" (
- set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
- set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
-)
-
-if "%1" == "" goto help
-
-if "%1" == "help" (
- :help
- echo.Please use `make ^` where ^ is one of
- echo. html to make standalone HTML files
- echo. dirhtml to make HTML files named index.html in directories
- echo. singlehtml to make a single large HTML file
- echo. pickle to make pickle files
- echo. json to make JSON files
- echo. htmlhelp to make HTML files and a HTML help project
- echo. qthelp to make HTML files and a qthelp project
- echo. devhelp to make HTML files and a Devhelp project
- echo. epub to make an epub
- echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
- echo. text to make text files
- echo. man to make manual pages
- echo. texinfo to make Texinfo files
- echo. gettext to make PO message catalogs
- echo. changes to make an overview over all changed/added/deprecated items
- echo. linkcheck to check all external links for integrity
- echo. doctest to run all doctests embedded in the documentation if enabled
- goto end
-)
-
-if "%1" == "clean" (
- for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
- del /q /s %BUILDDIR%\*
- goto end
-)
-
-if "%1" == "html" (
- %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The HTML pages are in %BUILDDIR%/html.
- goto end
-)
-
-if "%1" == "dirhtml" (
- %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
- goto end
-)
-
-if "%1" == "singlehtml" (
- %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
- goto end
-)
-
-if "%1" == "pickle" (
- %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished; now you can process the pickle files.
- goto end
-)
-
-if "%1" == "json" (
- %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished; now you can process the JSON files.
- goto end
-)
-
-if "%1" == "htmlhelp" (
- %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished; now you can run HTML Help Workshop with the ^
-.hhp project file in %BUILDDIR%/htmlhelp.
- goto end
-)
-
-if "%1" == "qthelp" (
- %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished; now you can run "qcollectiongenerator" with the ^
-.qhcp project file in %BUILDDIR%/qthelp, like this:
- echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Requests.qhcp
- echo.To view the help file:
- echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Requests.ghc
- goto end
-)
-
-if "%1" == "devhelp" (
- %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished.
- goto end
-)
-
-if "%1" == "epub" (
- %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The epub file is in %BUILDDIR%/epub.
- goto end
-)
-
-if "%1" == "latex" (
- %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
- goto end
-)
-
-if "%1" == "text" (
- %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The text files are in %BUILDDIR%/text.
- goto end
-)
-
-if "%1" == "man" (
- %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The manual pages are in %BUILDDIR%/man.
- goto end
-)
-
-if "%1" == "texinfo" (
- %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
- goto end
-)
-
-if "%1" == "gettext" (
- %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
- goto end
-)
-
-if "%1" == "changes" (
- %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
- if errorlevel 1 exit /b 1
- echo.
- echo.The overview file is in %BUILDDIR%/changes.
- goto end
-)
-
-if "%1" == "linkcheck" (
- %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
- if errorlevel 1 exit /b 1
- echo.
- echo.Link check complete; look for any errors in the above output ^
-or in %BUILDDIR%/linkcheck/output.txt.
- goto end
-)
-
-if "%1" == "doctest" (
- %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
- if errorlevel 1 exit /b 1
- echo.
- echo.Testing of doctests in the sources finished, look at the ^
-results in %BUILDDIR%/doctest/output.txt.
- goto end
-)
-
-:end
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+ set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+ set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+ set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+ :help
+ echo.Please use `make ^` where ^ is one of
+ echo. html to make standalone HTML files
+ echo. dirhtml to make HTML files named index.html in directories
+ echo. singlehtml to make a single large HTML file
+ echo. pickle to make pickle files
+ echo. json to make JSON files
+ echo. htmlhelp to make HTML files and a HTML help project
+ echo. qthelp to make HTML files and a qthelp project
+ echo. devhelp to make HTML files and a Devhelp project
+ echo. epub to make an epub
+ echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+ echo. text to make text files
+ echo. man to make manual pages
+ echo. texinfo to make Texinfo files
+ echo. gettext to make PO message catalogs
+ echo. changes to make an overview over all changed/added/deprecated items
+ echo. xml to make Docutils-native XML files
+ echo. pseudoxml to make pseudoxml-XML files for display purposes
+ echo. linkcheck to check all external links for integrity
+ echo. doctest to run all doctests embedded in the documentation if enabled
+ echo. coverage to run coverage check of the documentation if enabled
+ goto end
+)
+
+if "%1" == "clean" (
+ for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+ del /q /s %BUILDDIR%\*
+ goto end
+)
+
+
+REM Check if sphinx-build is available and fallback to Python version if any
+%SPHINXBUILD% 1>NUL 2>NUL
+if errorlevel 9009 goto sphinx_python
+goto sphinx_ok
+
+:sphinx_python
+
+set SPHINXBUILD=python -m sphinx.__init__
+%SPHINXBUILD% 2> nul
+if errorlevel 9009 (
+ echo.
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+ echo.installed, then set the SPHINXBUILD environment variable to point
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
+ echo.may add the Sphinx directory to PATH.
+ echo.
+ echo.If you don't have Sphinx installed, grab it from
+ echo.http://sphinx-doc.org/
+ exit /b 1
+)
+
+:sphinx_ok
+
+
+if "%1" == "html" (
+ %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+ goto end
+)
+
+if "%1" == "dirhtml" (
+ %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+ goto end
+)
+
+if "%1" == "singlehtml" (
+ %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+ goto end
+)
+
+if "%1" == "pickle" (
+ %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the pickle files.
+ goto end
+)
+
+if "%1" == "json" (
+ %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the JSON files.
+ goto end
+)
+
+if "%1" == "htmlhelp" (
+ %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+ goto end
+)
+
+if "%1" == "qthelp" (
+ %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+ echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Requests.qhcp
+ echo.To view the help file:
+ echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Requests.ghc
+ goto end
+)
+
+if "%1" == "devhelp" (
+ %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished.
+ goto end
+)
+
+if "%1" == "epub" (
+ %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The epub file is in %BUILDDIR%/epub.
+ goto end
+)
+
+if "%1" == "latex" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "latexpdf" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ cd %BUILDDIR%/latex
+ make all-pdf
+ cd %~dp0
+ echo.
+ echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "latexpdfja" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ cd %BUILDDIR%/latex
+ make all-pdf-ja
+ cd %~dp0
+ echo.
+ echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "text" (
+ %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The text files are in %BUILDDIR%/text.
+ goto end
+)
+
+if "%1" == "man" (
+ %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The manual pages are in %BUILDDIR%/man.
+ goto end
+)
+
+if "%1" == "texinfo" (
+ %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+ goto end
+)
+
+if "%1" == "gettext" (
+ %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+ goto end
+)
+
+if "%1" == "changes" (
+ %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.The overview file is in %BUILDDIR%/changes.
+ goto end
+)
+
+if "%1" == "linkcheck" (
+ %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+ goto end
+)
+
+if "%1" == "doctest" (
+ %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+ goto end
+)
+
+if "%1" == "coverage" (
+ %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Testing of coverage in the sources finished, look at the ^
+results in %BUILDDIR%/coverage/python.txt.
+ goto end
+)
+
+if "%1" == "xml" (
+ %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The XML files are in %BUILDDIR%/xml.
+ goto end
+)
+
+if "%1" == "pseudoxml" (
+ %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
+ goto end
+)
+
+:end
diff --git a/docs/requirements.txt b/docs/requirements.txt
deleted file mode 100644
index bf596036..00000000
--- a/docs/requirements.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-alabaster==0.7.3
-Sphinx==1.1.3
diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst
index 9c31950d..ddd6edf6 100644
--- a/docs/user/advanced.rst
+++ b/docs/user/advanced.rst
@@ -24,7 +24,7 @@ Let's persist some cookies across requests::
s = requests.Session()
s.get('http://httpbin.org/cookies/set/sessioncookie/123456789')
- r = s.get("http://httpbin.org/cookies")
+ r = s.get('http://httpbin.org/cookies')
print(r.text)
# '{"cookies": {"sessioncookie": "123456789"}}'
@@ -50,6 +50,7 @@ requests, even if using a session. This example will only send the cookies
with the first request, but not the second::
s = requests.Session()
+
r = s.get('http://httpbin.org/cookies', cookies={'from-my': 'browser'})
print(r.text)
# '{"cookies": {"from-my": "browser"}}'
@@ -129,14 +130,15 @@ request. The simple recipe for this is the following::
from requests import Request, Session
s = Session()
- req = Request('GET', url,
- data=data,
- headers=header
- )
+
+ req = Request('POST', url, data=data, headers=headers)
prepped = req.prepare()
# do something with prepped.body
+ prepped.body = 'No, I want exactly this as the body.'
+
# do something with prepped.headers
+ del prepped.headers['Content-Type']
resp = s.send(prepped,
stream=stream,
@@ -165,15 +167,15 @@ applied, replace the call to :meth:`Request.prepare()
from requests import Request, Session
s = Session()
- req = Request('GET', url,
- data=data
- headers=headers
- )
+ req = Request('GET', url, data=data, headers=headers)
prepped = s.prepare_request(req)
# do something with prepped.body
+ prepped.body = 'Seriously, send exactly these bytes.'
+
# do something with prepped.headers
+ prepped.headers['Keep-Dead'] = 'parrot'
resp = s.send(prepped,
stream=stream,
@@ -356,15 +358,16 @@ POST Multiple Multipart-Encoded Files
-------------------------------------
You can send multiple files in one request. For example, suppose you want to
-upload image files to an HTML form with a multiple file field 'images':
+upload image files to an HTML form with a multiple file field 'images'::
-To do that, just set files to a list of tuples of (form_field_name, file_info):
+To do that, just set files to a list of tuples of ``(form_field_name, file_info)``::
>>> url = 'http://httpbin.org/post'
- >>> multiple_files = [('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),
- ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]
+ >>> multiple_files = [
+ ('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),
+ ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]
>>> r = requests.post(url, files=multiple_files)
>>> r.text
{
@@ -491,7 +494,9 @@ set ``stream`` to ``True`` and iterate over the response with
lines = r.iter_lines()
# Save the first line for later or just skip it
+
first_line = next(lines)
+
for line in lines:
print(line)
@@ -506,11 +511,11 @@ If you need to use a proxy, you can configure individual requests with the
import requests
proxies = {
- "http": "http://10.10.1.10:3128",
- "https": "http://10.10.1.10:1080",
+ 'http': 'http://10.10.1.10:3128',
+ 'https': 'http://10.10.1.10:1080',
}
- requests.get("http://example.org", proxies=proxies)
+ requests.get('http://example.org', proxies=proxies)
You can also configure proxies by setting the environment variables
``HTTP_PROXY`` and ``HTTPS_PROXY``.
@@ -519,15 +524,14 @@ You can also configure proxies by setting the environment variables
$ export HTTP_PROXY="http://10.10.1.10:3128"
$ export HTTPS_PROXY="http://10.10.1.10:1080"
+
$ python
>>> import requests
- >>> requests.get("http://example.org")
+ >>> requests.get('http://example.org')
To use HTTP Basic Auth with your proxy, use the `http://user:password@host/` syntax::
- proxies = {
- "http": "http://user:pass@10.10.1.10:3128/",
- }
+ proxies = {'http': 'http://user:pass@10.10.1.10:3128/'}
To give a proxy for a specific scheme and host, use the
`scheme://hostname` form for the key. This will match for
@@ -535,9 +539,7 @@ any request to the given scheme and exact hostname.
::
- proxies = {
- "http://10.20.1.128": "http://10.10.1.10:5323",
- }
+ proxies = {'http://10.20.1.128': 'http://10.10.1.10:5323'}
Note that proxy URLs must include the scheme.
@@ -602,10 +604,13 @@ So, GitHub returns JSON. That's great, we can use the :meth:`r.json
::
>>> commit_data = r.json()
+
>>> print(commit_data.keys())
[u'committer', u'author', u'url', u'tree', u'sha', u'parents', u'message']
+
>>> print(commit_data[u'committer'])
{u'date': u'2012-05-10T11:10:50-07:00', u'email': u'me@kennethreitz.com', u'name': u'Kenneth Reitz'}
+
>>> print(commit_data[u'message'])
makin' history
@@ -645,9 +650,12 @@ already exists, we will use it as an example. Let's start by getting it.
>>> r = requests.get('https://api.github.com/repos/kennethreitz/requests/issues/482')
>>> r.status_code
200
+
>>> issue = json.loads(r.text)
+
>>> print(issue[u'title'])
Feature any http verb in docs
+
>>> print(issue[u'comments'])
3
@@ -658,9 +666,12 @@ Cool, we have three comments. Let's take a look at the last of them.
>>> r = requests.get(r.url + u'/comments')
>>> r.status_code
200
+
>>> comments = r.json()
+
>>> print(comments[0].keys())
[u'body', u'url', u'created_at', u'updated_at', u'user', u'id']
+
>>> print(comments[2][u'body'])
Probably in the "advanced" section
@@ -680,6 +691,7 @@ is to POST to the thread. Let's do it.
>>> body = json.dumps({u"body": u"Sounds great! I'll get right on it!"})
>>> url = u"https://api.github.com/repos/kennethreitz/requests/issues/482/comments"
+
>>> r = requests.post(url=url, data=body)
>>> r.status_code
404
@@ -692,9 +704,11 @@ the very common Basic Auth.
>>> from requests.auth import HTTPBasicAuth
>>> auth = HTTPBasicAuth('fake@example.com', 'not_a_real_password')
+
>>> r = requests.post(url=url, data=body, auth=auth)
>>> r.status_code
201
+
>>> content = r.json()
>>> print(content[u'body'])
Sounds great! I'll get right on it.
@@ -708,8 +722,10 @@ that.
>>> print(content[u"id"])
5804413
+
>>> body = json.dumps({u"body": u"Sounds great! I'll get right on it once I feed my cat."})
>>> url = u"https://api.github.com/repos/kennethreitz/requests/issues/comments/5804413"
+
>>> r = requests.patch(url=url, data=body, auth=auth)
>>> r.status_code
200
@@ -830,10 +846,9 @@ SSLv3:
""""Transport adapter" that allows us to use SSLv3."""
def init_poolmanager(self, connections, maxsize, block=False):
- self.poolmanager = PoolManager(num_pools=connections,
- maxsize=maxsize,
- block=block,
- ssl_version=ssl.PROTOCOL_SSLv3)
+ self.poolmanager = PoolManager(
+ num_pools=connections, maxsize=maxsize,
+ block=block, ssl_version=ssl.PROTOCOL_SSLv3)
.. _`described here`: http://www.kennethreitz.org/essays/the-future-of-python-http
.. _`urllib3`: https://github.com/shazow/urllib3
diff --git a/docs/user/install.rst b/docs/user/install.rst
index 5f0ef9c4..c3f0084e 100644
--- a/docs/user/install.rst
+++ b/docs/user/install.rst
@@ -7,23 +7,19 @@ This part of the documentation covers the installation of Requests.
The first step to using any software package is getting it properly installed.
-Distribute & Pip
-----------------
+Pip Install Requests
+--------------------
-Installing Requests is simple with `pip `_, just run
-this in your terminal::
+To install Requests, simply run this simple command in your terminal of choice::
$ pip install requests
-or, with `easy_install `_::
+If you don't have `pip `_ installed (tisk tisk!),
+`this Python installation guide `_
+can guide you through the process.
- $ easy_install requests
-
-But, you really `shouldn't do that `_.
-
-
-Get the Code
-------------
+Get the Source Code
+-------------------
Requests is actively developed on GitHub, where the code is
`always available `_.
@@ -32,16 +28,12 @@ You can either clone the public repository::
$ git clone git://github.com/kennethreitz/requests.git
-Download the `tarball `_::
+Or, download the `tarball `_::
$ curl -OL https://github.com/kennethreitz/requests/tarball/master
+ # optionally, zipball is also available (for Windows users).
-Or, download the `zipball `_::
-
- $ curl -OL https://github.com/kennethreitz/requests/zipball/master
-
-
-Once you have a copy of the source, you can embed it in your Python package,
-or install it into your site-packages easily::
+Once you have a copy of the source, you can embed it in your own Python
+package, or install it into your site-packages easily::
$ python setup.py install
diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst
index 10037fe6..d31f224e 100644
--- a/docs/user/quickstart.rst
+++ b/docs/user/quickstart.rst
@@ -37,15 +37,15 @@ get all the information we need from this object.
Requests' simple API means that all forms of HTTP request are as obvious. For
example, this is how you make an HTTP POST request::
- >>> r = requests.post("http://httpbin.org/post", data = {"key":"value"})
+ >>> r = requests.post('http://httpbin.org/post', data = {'key':'value'})
Nice, right? What about the other HTTP request types: PUT, DELETE, HEAD and
OPTIONS? These are all just as simple::
- >>> r = requests.put("http://httpbin.org/put", data = {"key":"value"})
- >>> r = requests.delete("http://httpbin.org/delete")
- >>> r = requests.head("http://httpbin.org/get")
- >>> r = requests.options("http://httpbin.org/get")
+ >>> r = requests.put('http://httpbin.org/put', data = {'key':'value'})
+ >>> r = requests.delete('http://httpbin.org/delete')
+ >>> r = requests.head('http://httpbin.org/get')
+ >>> r = requests.options('http://httpbin.org/get')
That's all well and good, but it's also only the start of what Requests can
do.
@@ -63,7 +63,7 @@ Requests allows you to provide these arguments as a dictionary, using the
following code::
>>> payload = {'key1': 'value1', 'key2': 'value2'}
- >>> r = requests.get("http://httpbin.org/get", params=payload)
+ >>> r = requests.get('http://httpbin.org/get', params=payload)
You can see that the URL has been correctly encoded by printing the URL::
@@ -76,7 +76,8 @@ URL's query string.
You can also pass a list of items as a value::
>>> payload = {'key1': 'value1', 'key2': ['value2', 'value3']}
- >>> r = requests.get("http://httpbin.org/get", params=payload)
+
+ >>> r = requests.get('http://httpbin.org/get', params=payload)
>>> print(r.url)
http://httpbin.org/get?key1=value1&key2=value2&key2=value3
@@ -87,6 +88,7 @@ We can read the content of the server's response. Consider the GitHub timeline
again::
>>> import requests
+
>>> r = requests.get('https://api.github.com/events')
>>> r.text
u'[{"repository":{"open_issues":0,"url":"https://github.com/...
@@ -131,6 +133,7 @@ use the following code::
>>> from PIL import Image
>>> from StringIO import StringIO
+
>>> i = Image.open(StringIO(r.content))
@@ -140,6 +143,7 @@ JSON Response Content
There's also a builtin JSON decoder, in case you're dealing with JSON data::
>>> import requests
+
>>> r = requests.get('https://api.github.com/events')
>>> r.json()
[{u'repository': {u'open_issues': 0, u'url': 'https://github.com/...
@@ -163,8 +167,10 @@ server, you can access ``r.raw``. If you want to do this, make sure you set
``stream=True`` in your initial request. Once you do, you can do this::
>>> r = requests.get('https://api.github.com/events', stream=True)
+
>>> r.raw
+
>>> r.raw.read(10)
'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03'
@@ -189,7 +195,6 @@ If you'd like to add HTTP headers to a request, simply pass in a ``dict`` to the
For example, we didn't specify our user-agent in the previous example::
- >>> import json
>>> url = 'https://api.github.com/some/endpoint'
>>> headers = {'user-agent': 'my-app/0.0.1'}
@@ -215,6 +220,7 @@ To do this, simply pass a dictionary to the ``data`` argument. Your
dictionary of data will automatically be form-encoded when the request is made::
>>> payload = {'key1': 'value1', 'key2': 'value2'}
+
>>> r = requests.post("http://httpbin.org/post", data=payload)
>>> print(r.text)
{
@@ -232,6 +238,7 @@ you pass in a ``string`` instead of a ``dict``, that data will be posted directl
For example, the GitHub API v3 accepts JSON-Encoded POST/PATCH data::
>>> import json
+
>>> url = 'https://api.github.com/some/endpoint'
>>> payload = {'some': 'data'}
@@ -426,10 +433,13 @@ response.
For example, GitHub redirects all HTTP requests to HTTPS::
>>> r = requests.get('http://github.com')
+
>>> r.url
'https://github.com/'
+
>>> r.status_code
200
+
>>> r.history
[]
@@ -438,16 +448,20 @@ If you're using GET, OPTIONS, POST, PUT, PATCH or DELETE, you can disable
redirection handling with the ``allow_redirects`` parameter::
>>> r = requests.get('http://github.com', allow_redirects=False)
+
>>> r.status_code
301
+
>>> r.history
[]
If you're using HEAD, you can enable redirection as well::
>>> r = requests.head('http://github.com', allow_redirects=True)
+
>>> r.url
'https://github.com/'
+
>>> r.history
[]
diff --git a/requests/__init__.py b/requests/__init__.py
index bd5b5b97..0091b387 100644
--- a/requests/__init__.py
+++ b/requests/__init__.py
@@ -46,7 +46,7 @@ __version__ = '2.9.1'
__build__ = 0x020901
__author__ = 'Kenneth Reitz'
__license__ = 'Apache 2.0'
-__copyright__ = 'Copyright 2015 Kenneth Reitz'
+__copyright__ = 'Copyright 2016 Kenneth Reitz'
# Attempt to enable urllib3's SNI support, if possible
try:
@@ -63,7 +63,7 @@ from .status_codes import codes
from .exceptions import (
RequestException, Timeout, URLRequired,
TooManyRedirects, HTTPError, ConnectionError,
- FileModeWarning,
+ FileModeWarning, ConnectTimeout, ReadTimeout
)
# Set default logging handler to avoid "No handler found" warnings.
diff --git a/requests/cookies.py b/requests/cookies.py
index b85fd2b6..eee5168f 100644
--- a/requests/cookies.py
+++ b/requests/cookies.py
@@ -277,6 +277,12 @@ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
dictionary[cookie.name] = cookie.value
return dictionary
+ def __contains__(self, name):
+ try:
+ return super(RequestsCookieJar, self).__contains__(name)
+ except CookieConflictError:
+ return True
+
def __getitem__(self, name):
"""Dict-like __getitem__() for compatibility with client code. Throws
exception if there are more than one cookie with name. In that case,
diff --git a/requests/utils.py b/requests/utils.py
index b4ceb1ef..d0f39c0f 100644
--- a/requests/utils.py
+++ b/requests/utils.py
@@ -81,7 +81,14 @@ def super_len(o):
)
if hasattr(o, 'tell'):
- current_position = o.tell()
+ try:
+ current_position = o.tell()
+ except (OSError, IOError):
+ # This can happen in some weird situations, such as when the file
+ # is actually a special file descriptor like stdin. In this
+ # instance, we don't know what the length is, so set it to zero and
+ # let requests chunk it instead.
+ current_position = total_length
return max(0, total_length - current_position)
diff --git a/requirements-to-freeze.txt b/requirements-to-freeze.txt
new file mode 100644
index 00000000..e8b9e354
--- /dev/null
+++ b/requirements-to-freeze.txt
@@ -0,0 +1,4 @@
+pytest
+pytest-cov
+pytest-httpbin
+sphinx
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index ad5da761..3d29de0c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,22 @@
-py==1.4.30
-pytest==2.8.1
-pytest-cov==2.1.0
-pytest-httpbin==0.0.7
-httpbin==0.4.0
-wheel
+alabaster==0.7.7
+Babel==2.2.0
+coverage==4.0.3
+decorator==4.0.9
+docutils==0.12
+Flask==0.10.1
+httpbin==0.4.1
+itsdangerous==0.24
+Jinja2==2.8
+MarkupSafe==0.23
+py==1.4.31
+Pygments==2.1.1
+pytest==2.8.7
+pytest-cov==2.2.1
+pytest-httpbin==0.2.0
+pytz==2015.7
+six==1.10.0
+snowballstemmer==1.2.1
+Sphinx==1.3.5
+sphinx-rtd-theme==0.1.9
+Werkzeug==0.11.4
+wheel==0.29.0
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index 5e409001..00000000
--- a/setup.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-[wheel]
-universal = 1
diff --git a/tests/test_requests.py b/tests/test_requests.py
index 1ee379c9..01e88da1 100755
--- a/tests/test_requests.py
+++ b/tests/test_requests.py
@@ -754,6 +754,38 @@ class TestRequests:
# make sure one can use items multiple times
assert list(items) == list(items)
+ def test_cookie_duplicate_names_different_domains(self):
+ key = 'some_cookie'
+ value = 'some_value'
+ domain1 = 'test1.com'
+ domain2 = 'test2.com'
+
+ jar = requests.cookies.RequestsCookieJar()
+ jar.set(key, value, domain=domain1)
+ jar.set(key, value, domain=domain2)
+ assert key in jar
+ items = jar.items()
+ assert len(items) == 2
+
+ # Verify that CookieConflictError is raised if domain is not specified
+ with pytest.raises(requests.cookies.CookieConflictError):
+ jar.get(key)
+
+ # Verify that CookieConflictError is not raised if domain is specified
+ cookie = jar.get(key, domain=domain1)
+ assert cookie == value
+
+ def test_cookie_duplicate_names_raises_cookie_conflict_error(self):
+ key = 'some_cookie'
+ value = 'some_value'
+ path = 'some_path'
+
+ jar = requests.cookies.RequestsCookieJar()
+ jar.set(key, value, path=path)
+ jar.set(key, value)
+ with pytest.raises(requests.cookies.CookieConflictError):
+ jar.get(key)
+
def test_time_elapsed_blank(self, httpbin):
r = requests.get(httpbin('get'))
td = r.elapsed
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 3d9d3936..5131e116 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -38,6 +38,20 @@ class TestSuperLen:
s.write('foobarbogus')
assert super_len(s) == 0
+ @pytest.mark.parametrize('error', [IOError, OSError])
+ def test_super_len_handles_files_raising_weird_errors_in_tell(self, error):
+ """
+ If tell() raises errors, assume the cursor is at position zero.
+ """
+ class BoomFile(object):
+ def __len__(self):
+ return 5
+
+ def tell(self):
+ raise error()
+
+ assert super_len(BoomFile()) == 0
+
def test_string(self):
assert super_len('Test') == 4