HttpClient removes Content-Length and causes 411
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- swift
- 領域
- networking
調査の方向性
Content-Length が長さ 0 の GET リクエストから削除される setTransportFraming の RequestValidation.swift から始めます。リクエストヘッダーがどのように設定されるかを追跡し、オーバーライドを公開できる場所を特定します。呼び出し側が GET リクエストに適切な Content-Length を強制でき、その結果のリクエストが Content-Length なしで 411 を返すサーバーで機能すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
When attempting to make GET calls with Django based server, I'm getting a 411 Length Required. Looking at the code in RequestValidation.swift, it is removing Content-Length from headers for GET calls. This may be according to specs but it appears that some servers still require this (probably set to 0). There should be some way to override this behavior or to cause it to force Content-Length to appear in the headers.
I have worked around this by implementing my own networking code using URLSession and the calls do work since I can control the headers exactly.
For reference, the code that is causing the problem is here:
private mutating func setTransportFraming(
method: HTTPMethod,
bodyLength: RequestBodyLength
) {
self.remove(name: "Content-Length")
self.remove(name: "Transfer-Encoding")
switch bodyLength {
case .known(0):
// if we don't have a body we might not need to send the Content-Length field
// https://tools.ietf.org/html/rfc7230#section-3.3.2
switch method {
case .GET, .HEAD, .DELETE, .CONNECT, .TRACE:
// A user agent SHOULD NOT send a Content-Length header field when the request
// message does not contain a payload body and the method semantics do not
// anticipate such a body.
break
default:
// A user agent SHOULD send a Content-Length in a request message when
// no Transfer-Encoding is sent and the request method defines a meaning
// for an enclosed payload body.
self.add(name: "Content-Length", value: "0")
}
case .known(let length):
self.add(name: "Content-Length", value: String(length))
case .unknown:
self.add(name: "Transfer-Encoding", value: "chunked")
}
}
- 主要言語
- Swift
- スター
- 1.1k
- フォーク
- 156
- 平均マージ
- 1時間 54分
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
swift-server/async-http-client のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
-
Invalid state: idleオープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
swift-server/async-http-client#927 · コメント 2 件 ·
-
Windows versionオープン
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
swift-server/async-http-client#923 · コメント 1 件 ·
-
Crash in `HTTP2ClientRequestHandler`対応中かも @rupayon123 が 18 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
swift-server/async-http-client の issue をすべて見る
似ている issue
-
bug good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
marcovisona/arca#5 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
luis-guillen/airy#2 ·
-
accessibility bug medium-priority mobile
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
lognorman20/monaco#6247 ·
-
documentation windows
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
521xueweihan/HelloGitHub#4060 ·