GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-102327: Extend docs for "url" and "headers" parameters to HTTPConnection.request() by davidfstr · Pull Request #102328 · python/cpython

Conversation

@davidfstr

@davidfstr davidfstr commented Feb 28, 2023 •
edited by Mariatta
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Added example on how to use the HTTPConnection object for making GET request.

Original issue: #102327

  • Issue: Clarify that "url" parameter to HTTPConnection.request(method, url) is usually an absolute path #102327

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

arhadthedev reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-bot bedevere-bot added the awaiting review label Feb 28, 2023
@bedevere-bot bedevere-bot mentioned this pull request Feb 28, 2023
Clarify that "url" parameter to HTTPConnection.request(method, url) is usually an absolute path #102327
Closed
@bedevere-bot bedevere-bot added docs Documentation in the Doc dir skip news labels Feb 28, 2023
@davidfstr
Document "url" parameter to HTTPConnection.request() (python#102327)
86275f8
@davidfstr
davidfstr force-pushed the f/http_url_clarify branch from a7cc220 to 86275f8 Compare April 4, 2023 23:07
Mariatta
Mariatta approved these changes Apr 30, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Apr 30, 2023
@Mariatta

Mariatta commented Apr 30, 2023

Copy link
Copy Markdown
Member

Looks good overall, I think this provides clarity to the doc.

One comment, and I'm being nitpicky here, can we use a different URL in the example, instead of xkcd? Can we use python.org as example? Or other Python-related website.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@davidfstr

davidfstr commented Apr 30, 2023

Copy link
Copy Markdown
Contributor Author

Can we use python.org as example? Or other Python-related website.

Sure. I'll tentatively put in: https://docs.python.org/3/

That URL satisfies the following useful conditions:

  • is owned by Python contributors
  • uses "https" rather than "http", which promotes "https"
  • uses a non-trivial path "/3/" (rather than just "/")
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@davidfstr
Alter example URL to be: https://docs.python.org/3/
912df17
@davidfstr davidfstr mentioned this pull request Apr 30, 2023
:rfc: should format links to sections sphinx-doc/sphinx#7027
Closed
AA-Turner
AA-Turner approved these changes Apr 30, 2023
View reviewed changes
Comment thread Doc/library/http.client.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@davidfstr
Alter RFC section link to appear with more-natural formatting
9013cd3
@merwok

merwok commented Apr 30, 2023

Copy link
Copy Markdown
Member

What do you think of moving the doc for url higher up (so that order of doc paragraphs matches order of parameters), and not using a note markup (which grabs attention and takes readers out of normal reading flow)?

The example could be kept at the end, after the documentation of each parameter.

Mariatta reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@davidfstr

davidfstr commented May 1, 2023

Copy link
Copy Markdown
Contributor Author

@merwok , makes sense. I'll plan to integrate those revisions later today.

merwok reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

davidfstr added 2 commits May 2, 2023 09:29
@davidfstr
Distribute new documentation to relevant parameter paragraphs
c0960c6
@davidfstr
Adjust formatting
231bd9e
@davidfstr

davidfstr commented May 2, 2023

Copy link
Copy Markdown
Contributor Author

Revisions integrated. Here's the updated graphical diff of the proposed changes:

Screen Shot 2023-05-02 at 9 26 26 AM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@davidfstr
Fix trailing whitespace
5a6293d
merwok
merwok reviewed May 2, 2023
View reviewed changes

@merwok merwok left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty great now!

Thanks for the screenshots. Note that pull requests have automatic preview websites for docs, which are even better to see results easily (although sometimes the link is a bit hidden):
https://cpython-previews--102328.org.readthedocs.build/en/102328/library/http.client.html#httpconnection-objects

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/http.client.rst Outdated
method *method* and the selector *url*.
method *method* and the request URI *url*. The provided *url* must be
an absolute path to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`
when using most HTTP methods (like ``GET`` or ``POST``).

@merwok merwok May 2, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line makes me wonder if PUT and PATCH are part of «most HTTP methods», so I have to follow the RFC link to see. It seems that yes, only OPTIONS * is given as a counter-example. I wonder if there is a way to rephrase that so that casual readers take away that url should nearly always be an absolute path, see link for exact rules.

What do other people think?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@davidfstr davidfstr May 3, 2023

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more specific phrasing would be:

The provided *url* must be an absolute path
to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`,
unless connecting to an HTTP proxy server or
using the ``OPTIONS`` or ``CONNECT`` methods.

And further down:

A :rfc:`Host header <2616#section-14.23>` must be provided
to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`,
unless connecting to an HTTP proxy server or
using the ``OPTIONS`` or ``CONNECT`` methods.

A reader would still have to follow the link to determine the actual rules if they were talking to an HTTP proxy server (somewhat common?) or using OPTIONS/CONNECT (rare?).

Comments?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merwok merwok May 3, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s very clear! The unless clause could even be in parentheses.

I never use proxies but I think there are two cases:

  • explicit proxy, when you send GET https://authority/path on a connection opened to http://proxy
  • transparent proxy, when you use an HTTP library that respects the http_proxy or https_proxy environment variables

I suppose the note here applies to the first kind only?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@davidfstr davidfstr May 4, 2023

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback applied. I think this change is ready to merge!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merwok merwok May 4, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you reply to the question about proxy? 🙂

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@davidfstr davidfstr May 5, 2023

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RFC 2616 §1.3 defines a "proxy" as:

An intermediary program which acts as both a server and a client
for the purpose of making requests on behalf of other clients.
Requests are serviced internally or by passing them on, with
possible translation, to other servers. A proxy MUST implement
both the client and server requirements of this specification. A
"transparent proxy" is a proxy that does not modify the request or
response beyond what is required for proxy authentication and
identification. A "non-transparent proxy" is a proxy that modifies
the request or response in order to provide some added service to
the user agent, such as group annotation services, media type
transformation, protocol reduction, or anonymity filtering. Except
where either transparent or non-transparent behavior is explicitly
stated, the HTTP proxy requirements apply to both types of
proxies.

Therefore I speculate that the following requirement from §5.1.2 applies when a Python program attempts to connect to any kind of proxy:

The absoluteURI form is REQUIRED when the request is being made to a
proxy.

I never use proxies myself so I have no empirical experience one way or the other.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merwok merwok May 5, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let’s hope the people using proxies know how to handle them!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

davidfstr reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@merwok

merwok commented May 2, 2023

Copy link
Copy Markdown
Member

Note for the dev who will merge: please edit the commit message to avoid reusing the whole original post here with its questions and screenshot

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

davidfstr added 2 commits May 4, 2023 08:57
@davidfstr
Clarify phrasing for when absolute paths are required
e6dc07c
@davidfstr
Fix whitespace
dcf2480
@davidfstr davidfstr changed the title gh-102327: Document "url" parameter to HTTPConnection.request() gh-102327: Extend docs for "url" and "headers" parameters to HTTPConnection.request() May 4, 2023
@bedevere-bot bedevere-bot added awaiting review and removed awaiting merge labels May 4, 2023
@merwok
merwok requested review from AA-Turner and Mariatta May 4, 2023 15:23
merwok
merwok approved these changes May 4, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels May 4, 2023
@davidfstr

davidfstr commented May 9, 2023

Copy link
Copy Markdown
Contributor Author

What are the next steps to move this review forward?

  • This review was previously approved by python maintainers @Mariatta and @AA-Turner , but that approval was reset when I cleaned up the PR title.
  • This review was also approved by @merwok. (Thanks for the helpful revisions!)

(1) Would it be helpful if I squashed/rebased this commit to the tip of the main branch?

(2) Do I need to summon someone with merge permissions? If so, is there a list of such folks publicly listed?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Mariatta

Mariatta commented May 9, 2023

Copy link
Copy Markdown
Member

I will re-review later today from computer. Thanks.

davidfstr reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AA-Turner
AA-Turner approved these changes May 9, 2023
View reviewed changes
@merwok

merwok commented May 9, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

The approval was reset by me actually, not a title change!

Note that all PRs for CPython are squash merged, so rebases are not needed. (In fact the devguide recommends against them, as force pushes do weird things for reviewers: ghost notifications, comments losing context)

davidfstr reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Éric
Merge branch 'main' into f/http_url_clarify
f6f6e48
Mariatta
Mariatta approved these changes May 9, 2023
View reviewed changes

@Mariatta Mariatta left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting review and removed awaiting merge labels May 9, 2023
@Mariatta
Mariatta merged commit 7ba6288 into python:main May 9, 2023
@bedevere-bot bedevere-bot removed the awaiting review label May 9, 2023
@Mariatta Mariatta added the needs backport to 3.11 only security fixes label May 9, 2023
@miss-islington

miss-islington commented May 9, 2023

Copy link
Copy Markdown
Contributor

Thanks @davidfstr for the PR, and @Mariatta for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@terryjreedy terryjreedy removed the needs backport to 3.11 only security fixes label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@merwok merwok merwok approved these changes
@Mariatta Mariatta Mariatta approved these changes
@AA-Turner AA-Turner AA-Turner approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@davidfstr @Mariatta @merwok @miss-islington @AA-Turner @terryjreedy @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.