Request for clarification: URL parsing behavior in Requests (RFC 3986 vs WHATWG)

オープン
#7,141 コメント 2 件 リアクション 2 件 担当者 0 名 GitHub で見る

@cici-czx がすでに取り組んでいます。

2026年1月7日 から。

  • #7307 @nuglifeleoji による — マージされずにクローズ

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
ドキュメント
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

まず、引用されている issue #5886 を確認し、ここにリンクされている RFC 3986、RFC 7230、WHATWG URL のリファレンスと観測された動作を比較します。ソースファイルもテストも特定されていません。maintainer が Requests が意図的に従っている仕様または互換性動作を明確にすれば、issue は完了です。

索引モデルが issue の本文から書いたものです。

説明

Hello Requests maintainers,

Thank you for maintaining Requests and for the extensive discussions around URL parsing behavior over the years.

I am seeking clarification regarding which specification(s) Requests follows for URL parsing, particularly for HTTP(S) URLs, as I have observed behaviors that appear to align with different standards.

In previous discussions, Requests developers have noted that the library primarily follows RFC-based specifications. For example, in https://github.com/psf/requests/issues/5886, it is stated that:

RFC 3986 is the standard that Requests and urllib3 primarily use as a reference for their URL parsers.

This suggests that Requests' URL parsing logic is grounded in RFC 3986, with HTTP semantics further informed by RFC 7230.

However, I have observed a behavior in Requests that seems closer to the WHATWG URL Standard.

Specifically, when parsing HTTP URLs whose hostname contains a backslash (), Requests appears to treat \ as a delimiter equivalent to /, effectively separating the authority from the path.
This behavior is consistent with the WHATWG URL Standard's definition of the authority parsing state (see: https://url.spec.whatwg.org/#authority-state).

Image

By contrast: RFC 3986 treats \ as a disallowed character in URLs and does not define it as a structural delimiter. Many RFC-oriented parsers (e.g., urllib.parse.urlparse) either reject such URLs or treat \ as an ordinary character, rather than as a path/authority separator.

Image
Question

Could you please clarify:

Whether Requests intentionally references or aligns with the WHATWG URL Standard for any part of its URL parsing behavior (especially hostname handling)?

Or whether the observed behavior is still considered RFC 3986–based, but with pragmatic extensions or legacy compatibility considerations?

Understanding this would be very helpful for accurately characterizing Requests' parsing semantics and for reasoning about cross-component URL parsing consistency.

Thank you very much for your time and clarification.

主要言語
Python
スター
54.7k
フォーク
10.8k
平均マージ
18分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

psf/requests のほかの issue

psf/requests の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。