feat(client): enable CONNECT requests through the Client

While the upgrades feature enabled HTTP upgrades in both and the server and client, and the goal was for `CONNECT` requests to work as well, only the server could use them for `CONNECT`. The `Client` had some specific code rejecting `CONNECT` requests, and this removes it and prepares the `Client` to handle them correctly.
This commit is contained in:
Sean McArthur
2018-06-22 21:00:28 -07:00
committed by GitHub
parent f698b03e57
commit 2a3844acc3
4 changed files with 224 additions and 56 deletions

View File

@@ -61,6 +61,8 @@ pub(crate) enum Kind {
UnsupportedVersion,
/// User tried to create a CONNECT Request with the Client.
UnsupportedRequestMethod,
/// User tried to send a Request with Client with non-absolute URI.
AbsoluteUriRequired,
/// User tried polling for an upgrade that doesn't exist.
NoUpgrade,
@@ -117,6 +119,7 @@ impl Error {
Kind::Closed |
Kind::UnsupportedVersion |
Kind::UnsupportedRequestMethod |
Kind::AbsoluteUriRequired |
Kind::NoUpgrade |
Kind::Execute => true,
_ => false,
@@ -224,6 +227,10 @@ impl Error {
Error::new(Kind::UnsupportedRequestMethod, None)
}
pub(crate) fn new_user_absolute_uri_required() -> Error {
Error::new(Kind::AbsoluteUriRequired, None)
}
pub(crate) fn new_user_no_upgrade() -> Error {
Error::new(Kind::NoUpgrade, None)
}
@@ -303,6 +310,7 @@ impl StdError for Error {
Kind::Http2 => "http2 general error",
Kind::UnsupportedVersion => "request has unsupported HTTP version",
Kind::UnsupportedRequestMethod => "request has unsupported HTTP method",
Kind::AbsoluteUriRequired => "client requires absolute-form URIs",
Kind::NoUpgrade => "no upgrade available",
Kind::ManualUpgrade => "upgrade expected but low level API in use",
Kind::Execute => "executor failed to spawn task",