Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Make reason_phrase a String #1862

Merged
merged 5 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2804,7 +2804,6 @@ impl Connection {
reason_phrase,
} => {
self.stats.borrow_mut().frame_rx.connection_close += 1;
let reason_phrase = String::from_utf8_lossy(&reason_phrase);
qinfo!(
[self],
"ConnectionClose received. Error code: {:?} frame type {:x} reason {}",
Expand Down
8 changes: 4 additions & 4 deletions neqo-transport/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub enum Frame<'a> {
frame_type: u64,
// Not a reference as we use this to hold the value.
// This is not used in optimized builds anyway.
reason_phrase: Vec<u8>,
reason_phrase: String,
},
HandshakeDone,
AckFrequency {
Expand Down Expand Up @@ -618,7 +618,7 @@ impl<'a> Frame<'a> {
Ok(Self::ConnectionClose {
error_code,
frame_type,
reason_phrase,
reason_phrase: String::from_utf8_lossy(&reason_phrase).to_string(),
})
}
FRAME_TYPE_HANDSHAKE_DONE => Ok(Self::HandshakeDone),
Expand Down Expand Up @@ -925,7 +925,7 @@ mod tests {
let f = Frame::ConnectionClose {
error_code: CloseError::Transport(0x5678),
frame_type: 0x1234,
reason_phrase: vec![0x01, 0x02, 0x03],
reason_phrase: String::from_utf8(vec![0x01, 0x02, 0x03]).unwrap(),
};

just_dec(&f, "1c80005678523403010203");
Expand All @@ -936,7 +936,7 @@ mod tests {
let f = Frame::ConnectionClose {
error_code: CloseError::Application(0x5678),
frame_type: 0,
reason_phrase: vec![0x01, 0x02, 0x03],
reason_phrase: String::from_utf8(vec![0x01, 0x02, 0x03]).unwrap(),
};

just_dec(&f, "1d8000567803010203");
Expand Down
2 changes: 1 addition & 1 deletion neqo-transport/src/qlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ impl From<&Frame<'_>> for QuicFrame {
},
error_code: Some(error_code.code()),
error_code_value: Some(0),
reason: Some(String::from_utf8_lossy(reason_phrase).to_string()),
reason: Some(reason_phrase.to_string()),
trigger_frame_type: Some(*frame_type),
},
Frame::HandshakeDone => QuicFrame::HandshakeDone,
Expand Down
Loading