Quickstart timeout example shows HTTP connection for HTTPS request

Open Beginner friendly
#7,646 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
85/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
documentation

Research direction

The problem is in the Timeouts section of the Requests Quickstart page, linked in the issue. Its sample traceback shows HTTPConnectionPool on port 80 for an https://github.com/ URL, but the library reports HTTPSConnectionPool on port 443. Reproduce with the snippet in the issue (timeout=0.001) and update the documented output to match. Done when the shown exception and port agree with the https URL in the example.

Written by the indexing model from the issue text.

Description

The Requests Quickstart documentation differs from the Timeouts section as the example given uses an HTTPS URL, but the traceback shows a HTTP connection on port 80 instead of port 443.

I tested the example and received a different result than the expected result shown in the Quickstart documentation.

Referring to the sample https://github.com, an HTTPS connection should use port 443. The traceback should be the same.

The Quickstart documentation shows HTTPConnectionPool(host='github.com', port=80

I tried the example on my MacBook using Requests 2.32.3 and got a ConnectTimeout that said HTTPSConnectionPool(host='github.com', port=443

The current documentation seems to be outdated and does not have the correct traceback.

Documentation link:
https://requests.readthedocs.io/en/latest/user/quickstart/#timeouts

I made a Python file on Visual Studio Code and wrote this code:

import requests

print("Requests version:", requests.__version__)

try:
    requests.get("https://github.com/", timeout=0.001)
except requests.exceptions.RequestException as error:
    print("Exception type:", type(error).__name__)
    print("Error:", error)

I used Mac OS, Python 3.12, Requests 2.32.3 and Visual Studio Code.

{
  "chardet": {
    "version": null
  },
  "charset_normalizer": {
    "version": "3.4.7"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "3.14"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.12.3"
  },
  "platform": {
    "release": "23.5.0",
    "system": "Darwin"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.32.3"
  },
  "system_ssl": {
    "version": "300000d0"
  },
  "urllib3": {
    "version": "2.7.0"
  },
  "using_charset_normalizer": true,
  "using_pyopenssl": false
}
Dominant language
Python
Stars
54.7k
Forks
10.8k
Avg merge
18m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from psf/requests

All issues in psf/requests

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.