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 — Clarify that "url" parameter to HTTPConnection.request(method, url) is usually an absolute path · Issue #102327 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
Clarify that "url" parameter to HTTPConnection.request(method, url) is usually an absolute path#102327
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@davidfstr
davidfstr
opened on Feb 28, 2023
Issue body actions

Documentation

The current documentation for HTTPConnection.request(method, url) looks like:


Screen Shot 2023-02-28 at 8 56 01 AM


No description of the "url" parameter is provided besides its name. One might easily assume (as I did originally) that an absolute URL such as https://xkcd.com was expected here.

However if you look at how the request() method is implemented, you'll notice that it creates an HTTP request line using the method and url parameters verbatim:

  • For example: HTTPConnection.request("GET", "/") will create an HTTP request beginning with GET / HTTP/1.1.
  • And HTTPConnection.request("GET", "https://xkcd.com") will create an HTTP request beginning with GET https://xkcd.com HTTP/1.1.

According to RFC 2616 §5.1.2, (1) the "url" in the above examples must be an absolute path (like /) and (2) the "Host" header must be provided.

I recently discovered that a website downloader program of mine was generating improper HTTP requests that were confusing WordPress sites because I was incorrectly passing an absolute URL as the "url" parameter to request() rather than passing an absolute path.

I think it would be worth extending the documentation to explain the above constraints on the "url" parameter (and the requirement of the "Host" header), so that it is easier to use the request() method correctly to generate a well-formed HTTP request.

I already have a PR proposing specific changes, which I will post shortly.

Linked PRs

  • gh-102327: Extend docs for "url" and "headers" parameters to HTTPConnection.request() #102328
  • [3.11] gh-102327: Extend docs for "url" and "headers" parameters to HTTPConnection.request() #104339

Activity

  1. davidfstr
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Feb 28, 2023
  2. davidfstr
    changed the title [-]Clarify that "url" parameter to HTTPConnection.request(method, url) is usually not an URL[/-] [+]Clarify that "url" parameter to HTTPConnection.request(method, url) is usually an absolute path[/+] on Feb 28, 2023
  3. davidfstr
    added a commit that references this issue on Apr 4, 2023

    Document "url" parameter to HTTPConnection.request() (python#102327)

    86275f8
  4. davidfstr commented on Apr 4, 2023

    @davidfstr
    davidfstr
    on Apr 4, 2023
    ContributorAuthor
    More actions

    Hello, is there a reviewer with expertise in the http.client documentation that is available to review the PR associated with this issue?

    (I am posting this ping >1 month after no activity, as recommended by the dev guide.)

  5. Mariatta
    added a commit that references this issue on May 9, 2023

    gh-102327: Extend docs for "url" and "headers" parameters to HTTPConn…

    7ba6288
  6. miss-islington
    added a commit that references this issue on May 9, 2023

    pythongh-102327: Extend docs for "url" and "headers" parameters to HT…

    395d089
  7. Mariatta
    added a commit that references this issue on May 9, 2023

    [3.11] gh-102327: Extend docs for "url" and "headers" parameters to H…

    fffdbf4
  8. Mariatta commented on May 9, 2023

    @Mariatta
    Mariatta
    on May 9, 2023
    Member
    More actions

    Thanks for the PR. I've merged it and it will be backported to 3.11.

    Reacted by Gregory P. Smith
  9. Mariatta
    closed this as completedon May 9, 2023
  10. carljm
    added a commit that references this issue on May 10, 2023

    Merge branch 'main' into fixloadsuperspec

    5976df9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.