Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2bbeca9

Browse files
committed
Dedicated error for redirect replies.
vi/websocat#173
1 parent2245bee commit2bbeca9

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

‎Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name ="websocket"
3-
version ="0.26.5"
3+
version ="0.27.0"
44
authors = ["cyderize <admin@cyderize.org>","Michael Eden <themichaeleden@gmail.com>"]
55
edition ="2018"
66

‎src/client/builder.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,12 @@ impl<'u> ClientBuilder<'u> {
888888
let status =StatusCode::from_u16(response.subject.0);
889889

890890
if status !=StatusCode::SwitchingProtocols{
891+
if status.is_redirection(){
892+
match response.headers.get::<hyper::header::Location>(){
893+
Some(x) =>returnErr(WebSocketOtherError::RedirectError(status, x.to_string())).map_err(towse),
894+
None =>(),
895+
}
896+
}
891897
returnErr(WebSocketOtherError::StatusCodeError(status)).map_err(towse);
892898
}
893899

‎src/result.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ pub enum WebSocketOtherError {
4343
ResponseError(&'staticstr),
4444
/// Received unexpected status code
4545
StatusCodeError(StatusCode),
46+
/// Received 3XX status code with a Location header
47+
RedirectError(StatusCode,String),
4648
/// An HTTP parsing error
4749
HttpError(HttpError),
4850
/// A URL parsing error
@@ -74,6 +76,12 @@ impl fmt::Display for WebSocketOtherError {
7476
"WebSocketError: Received unexpected status code ({})",
7577
e
7678
),
79+
WebSocketOtherError::RedirectError(st, loc) =>write!(
80+
fmt,
81+
"WebSocketError: Redirected ({}) to {}",
82+
st,
83+
loc,
84+
),
7785
WebSocketOtherError::HttpError(e) =>write!(fmt,"WebSocket HTTP error: {}", e),
7886
WebSocketOtherError::UrlError(e) =>write!(fmt,"WebSocket URL parse error: {}", e),
7987
WebSocketOtherError::IoError(e) =>write!(fmt,"WebSocket I/O error: {}", e),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp