This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: change httplib docs POST example
Type: Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: barbi, docs@python, eric.araujo, ezio.melotti, georg.brandl, orsenthil, petri.lehtinen, python-dev
Priority: low Keywords: easy, patch

Created on 2011-07-10 09:05 by georg.brandl, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
http_example.diff barbi, 2011-07-16 08:26 Changed example to httpstat.us review
http_example2.diff barbi, 2011-07-20 07:55 http example using bugs.python.org review
Messages (13)
msg140074 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-07-10 09:05
The POST example in the httplib docs references musi-cal.mojam.com, which is now defunct.
msg140229 - (view) Author: Bharadwaj (barbi) Date: 2011-07-13 08:18
Newbie to python dev. 
This looks like a good issue to get started with and I am interested in creating a patch.
What should the new URL be? python.org:80?
msg140230 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-07-13 08:22
You'll need a page that accepts POST requests, possibly returning some meaningful value, and without side effects (e.g. adding messages is usually done via POST, but we don't want a new message for every user that tries the example).
msg140232 - (view) Author: Bharadwaj (barbi) Date: 2011-07-13 08:35
Is there someway to create a test page in python.org instead of an external domain? This can ensure many people have access to it and will not become defunct.
Please suggest next steps to proceed with this ticket.
msg140234 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-07-13 08:40
FWIW the 'show issue' button on the left sidebar of http://bugs.python.org/ uses POST, so maybe you could send an issue number as request there to get back the issue page.
msg140449 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2011-07-15 18:09
There's also http://httpstat.us/. You can send any request (also POST) to http://httpstat.us/200 and it gives you a 200 OK response.

I recall seeing other similar services, but didn't find them quickly.
msg140481 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-07-16 08:41
httpstat.us is has been registered quite recently, and is titled as an "experiment" in the footer.  I'd rather use something more likely to be persistent.  bugs.python.org seems a better choice.
msg140483 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2011-07-16 09:06
Also, it does not say or "advertise" about POST, it gives examples for
GET. I find Ezio's suggestion using bugs.python.org as a good one.
msg140554 - (view) Author: Bharadwaj (barbi) Date: 2011-07-18 01:58
Newbie here. Please be patient.

When I tried using the POST form in this page, I ran into minor issues.
1. The form returns a 302 to the actual issue page. Some other example with 200 may be better.
2. The params are a little weird, with '@' in the names. Might be confusing for newbies.
3. Form action param is '#', which is not a great example.

Please suggest if I should continue with this example or find a better one.

Code:
import http.client, urllib.parse
params = urllib.parse.urlencode({'@number': 12524, '@type': 'issue', '@action': 'show'})
headers = {"Content-type": "application/x-www-form-urlencoded",
           "Accept": "text/plain"}
conn = http.client.HTTPConnection("bugs.python.org")
conn.request("POST", "#", params, headers)
response = conn.getresponse()
print(response.status, response.reason)
data = response.read()
conn.close()
data
b'Redirecting to <a href="http://bugs.python.org/issue12524">http://bugs.python.org/issue12524</a>'
msg140660 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-07-19 13:05
1. 3xx codes are as fine as 200, IIRC.

2. Agreed, Roundup as very strange form parameters and URIs in general, but that’s not something we can change.

3. Maybe the empty string would work?  (It’s a URI reference which means “same URI as the resource where the form was found” IOW same page).


Alternate idea: use example.org.  People won’t be able to actually run the example, but is it really important?
msg140712 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2011-07-20 00:06
Hello Eric,

On Tue, Jul 19, 2011 at 01:05:59PM +0000, Éric Araujo wrote:

> Alternate idea: use example.org.  People won’t be able to actually
> run the example, but is it really important?

The whole idea is present a usable example. Please don't suggest
unusable example. example.org does not support POST.
msg140731 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-07-20 14:02
New changeset ab4d403cb0c0 by Senthil Kumaran in branch '3.2':
Fix closes issue12524 - update http.client POST example with a working example.
http://hg.python.org/cpython/rev/ab4d403cb0c0

New changeset bc71fff2b6c7 by Senthil Kumaran in branch 'default':
merge from 3.2 - Fix closes issue12524 - update http.client POST example with a working example.
http://hg.python.org/cpython/rev/bc71fff2b6c7

New changeset b754641a429f by Senthil Kumaran in branch '2.7':
merge from 3.2 - Fix closes issue12524 - update http.client POST example with a working example. - Patch contributed by Bharadwaj
http://hg.python.org/cpython/rev/b754641a429f
msg140734 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2011-07-20 14:03
Thanks for the patch, Bharadwaj.
History
Date User Action Args
2022-04-11 14:57:19adminsetgithub: 56733
2011-07-20 14:03:55orsenthilsetmessages: + msg140734
2011-07-20 14:02:52python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg140731

resolution: fixed
stage: resolved
2011-07-20 07:55:45barbisetfiles: + http_example2.diff
2011-07-20 00:06:30orsenthilsetmessages: + msg140712
2011-07-19 13:05:59eric.araujosetnosy: + eric.araujo
messages: + msg140660
2011-07-18 01:58:54barbisetmessages: + msg140554
2011-07-16 09:06:36orsenthilsetnosy: + orsenthil
messages: + msg140483
2011-07-16 08:41:10georg.brandlsetmessages: + msg140481
2011-07-16 08:26:55barbisetfiles: + http_example.diff
keywords: + patch
2011-07-15 18:09:40petri.lehtinensetnosy: + petri.lehtinen
messages: + msg140449
2011-07-13 08:40:51ezio.melottisetmessages: + msg140234
2011-07-13 08:35:20barbisetmessages: + msg140232
2011-07-13 08:22:28ezio.melottisetnosy: + ezio.melotti
messages: + msg140230
2011-07-13 08:18:41barbisetnosy: + barbi
messages: + msg140229
2011-07-10 09:05:31georg.brandlcreate