Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ impl Sequence {
}
}

pub fn color_for_status(code: u16) -> Sequence {
match code {
200..=299 => Sequence::Green,
300..=399 => Sequence::Yellow,
_ => Sequence::Red,
}
}

#[derive(Debug, Clone)]
pub struct Printer {
buf: Vec<u8>,
Expand Down
8 changes: 0 additions & 8 deletions src/http/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,6 @@ pub(super) fn flush_stderr(mut printer: core::Printer) {
let _ = printer.flush_to(&mut stderr);
}

pub(super) fn color_for_status(code: u16) -> core::Sequence {
match code {
200..=299 => core::Sequence::Green,
300..=399 => core::Sequence::Yellow,
_ => core::Sequence::Red,
}
}

pub(crate) fn request_target(url: &Url) -> String {
let mut target = if url.path().is_empty() {
"/".to_string()
Expand Down
1 change: 1 addition & 0 deletions src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ mod response;
mod retry;
pub(crate) mod transport;

pub(crate) use core::color_for_status;
pub(crate) use metadata::{
apply_headers, apply_query, has_authority_scheme, load_session, normalize_url, request_target,
save_session, validate_ech_for_url,
Expand Down
10 changes: 1 addition & 9 deletions src/websocket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ fn print_response_metadata(
}
printer.write_styled(ws_version_label(response.version()), &[core::Sequence::Dim]);
printer.push_str(" ");
let status_color = color_for_status(status.as_u16());
let status_color = core::color_for_status(status.as_u16());
printer.write_styled(
&status.as_u16().to_string(),
&[status_color, core::Sequence::Bold],
Expand Down Expand Up @@ -718,14 +718,6 @@ fn ws_version_label(version: WsVersion) -> &'static str {
}
}

fn color_for_status(code: u16) -> core::Sequence {
match code {
200..=299 => core::Sequence::Green,
300..=399 => core::Sequence::Yellow,
_ => core::Sequence::Red,
}
}

fn flush_stderr(mut printer: core::Printer) {
let mut stderr = std::io::stderr();
let _ = printer.flush_to(&mut stderr);
Expand Down
Loading