Quickstart timeout example shows HTTP connection for HTTPS request

Đang mở Phù hợp với người mới
#7,646 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
85/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
documentation

Hướng nghiên cứu

Vấn đề nằm ở phần Timeouts của trang Requests Quickstart được liên kết trong issue. Traceback mẫu trong tài liệu hiển thị HTTPConnectionPool ở cổng 80 cho URL https://github.com/, nhưng thư viện báo HTTPSConnectionPool ở cổng 443. Hãy tái tạo lỗi bằng đoạn mã trong issue (timeout=0.001) và cập nhật kết quả được ghi trong tài liệu cho khớp. Hoàn thành khi ngoại lệ hiển thị và cổng khớp với URL https trong ví dụ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
}
Ngôn ngữ chính
Python
Star
54.7k
Fork
10.8k
Merge trung bình
18 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của psf/requests

Tất cả issue của psf/requests

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.