diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-02-25 15:22:50 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-02-25 15:22:50 (GMT) |
commit | 7cae336890b96fca94a84983003469a17f65ae8c (patch) | |
tree | b52a822446c55f30895fecef2dae55eec9e278ac /Doc | |
parent | 3e97585b3e24b23e0e2cef4d8ccced003e271dfc (diff) | |
download | cpython-7cae336890b96fca94a84983003469a17f65ae8c.zip cpython-7cae336890b96fca94a84983003469a17f65ae8c.tar.gz cpython-7cae336890b96fca94a84983003469a17f65ae8c.tar.bz2 |
whatsnew: Request.method can be overridden in subclasses (#18978).
Jason doced the change in the constructor *method* description, but
not the description of Request.method, so I added the change there
as well.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/urllib.request.rst | 17 | ||||
-rw-r--r-- | Doc/whatsnew/3.4.rst | 5 |
2 files changed, 17 insertions, 5 deletions
diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index 20449d9..6ac9081 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -218,7 +218,7 @@ The following classes are provided: fetching of the image, this should be true. *method* should be a string that indicates the HTTP request method that - will be used (e.g. ``'HEAD'``). Its value is stored in the + will be used (e.g. ``'HEAD'``). If provided, its value is stored in the :attr:`~Request.method` attribute and is used by :meth:`get_method()`. Subclasses may indicate a default method by setting the :attr:`~Request.method` attribute in the class itself. @@ -440,13 +440,20 @@ request. .. attribute:: Request.method - The HTTP request method to use. This value is used by - :meth:`~Request.get_method` to override the computed HTTP request - method that would otherwise be returned. This attribute is initialized with - the value of the *method* argument passed to the constructor. + The HTTP request method to use. By default its value is :const:`None`, + which means that :meth:`~Request.get_method` will do its normal computation + of the method to be used. Its value can be set (thus overriding the default + computation in :meth:`~Request.get_method`) either by providing a default + value by setting it at the class level in a :class:`Request` subclass, or by + passing a value in to the :class:`Request` constructor via the *method* + argument. .. versionadded:: 3.3 + .. versionchanged:: 3.4 + A default value can now be set in subclasses; previously it could only + be set via the constructor argument. + .. method:: Request.get_method() diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst index 528a818..cc1cafc 100644 --- a/Doc/whatsnew/3.4.rst +++ b/Doc/whatsnew/3.4.rst @@ -1272,6 +1272,11 @@ urllib :class:`~urllib.request.DataHandler` class. (Contributed by Mathias Panzenböck in :issue:`16423`.) +The http method that will be used by a :class:`~urllib.request.Request` class +can now be specified by setting a :class:`~urllib.request.Request.method` +class attribute on the subclass. (Contributed by Jason R Coombs in +:issue:`18978`.) + unittest -------- |