Hyper を使用して HTTP 要求を送信していますが、応答に複数の Cookie が含まれている場合、Hyper はそれらを 1 つに結合し、解析手順に失敗します。
たとえば、これは単純な PHP スクリプトです。
<?php
setcookie("hello", "world");
setcookie("foo", "bar");
curl を使用した応答:
$ curl -sLD - http://local.example.com/test.php
HTTP/1.1 200 OK
Date: Sat, 24 Dec 2016 09:24:04 GMT
Server: Apache/2.4.25 (Unix) PHP/7.0.14
X-Powered-By: PHP/7.0.14
Set-Cookie: hello=world
Set-Cookie: foo=bar
Content-Length: 0
Content-Type: text/html; charset=UTF-8
ただし、次の Rust コードの場合:
let client = Client::new();
let response = client.get("http://local.example.com/test.php")
.send()
.unwrap();
println!("{:?}", response);
for header in response.headers.iter() {
println!("{}: {}", header.name(), header.value_string());
}
...出力は次のようになります。
Response { status: Ok, headers: Headers { Date: Sat, 24 Dec 2016 09:31:54 GMT, Server: Apache/2.4.25 (Unix) PHP/7.0.14, X-Powered-By: PHP/7.0.14, Set-Cookie: hello=worldfoo=bar, Content-Length: 0, Content-Type: text/html; charset=UTF-8, }, version: Http11, url: "http://local.example.com/test.php", status_raw: RawStatus(200, "OK"), message: Http11Message { is_proxied: false, method: None, stream: Wrapper { obj: Some(Reading(SizedReader(remaining=0))) } } }
Date: Sat, 24 Dec 2016 09:31:54 GMT
Server: Apache/2.4.25 (Unix) PHP/7.0.14
X-Powered-By: PHP/7.0.14
Set-Cookie: hello=worldfoo=bar
Content-Length: 0
Content-Type: text/html; charset=UTF-8
これは私には本当に奇妙に思えます。Wireshark を使用して応答をキャプチャしたところ、2 つの Set-Cookie
ヘッダーが含まれていました。Hyperのドキュメントもチェックしましたが、手がかりがありません...
HyperVecMap<HeaderName, Item>
がヘッダーを格納するために内部的に a を使用していることに気付きました。それで、彼らはそれらを1つに連結しますか?その後、個々の Cookie にどのように分割すればよいでしょうか。