use crate::http::header_processor::HttpResponseHead;
#[derive(Debug, Clone)]
pub enum ProxyResponse {
Connected(HttpResponseHead),
AuthRequired {
response: HttpResponseHead,
},
Error {
status_code: u16,
reason: String,
},
}
impl ProxyResponse {
pub(crate) fn from_head(head: HttpResponseHead) -> Self {
match aria2_protocol::http::proxy::classify_proxy_response(head.status_code) {
aria2_protocol::http::proxy::ProxyResponseKind::Connected => {
ProxyResponse::Connected(head)
}
aria2_protocol::http::proxy::ProxyResponseKind::AuthenticationRequired => {
ProxyResponse::AuthRequired { response: head }
}
aria2_protocol::http::proxy::ProxyResponseKind::Error => ProxyResponse::Error {
status_code: head.status_code,
reason: head.reason_phrase.clone(),
},
}
}
}