Skip to content

Commit 4021c57

Browse files
committed
feat(ext): remove ReasonPhrase::from_bytes_unchecked() method
BREAKING CHANGE: The `ReasonPhrase::from_bytes_unchecked()` method is gone. Use `from_static()` or `TryFrom` to construct one.
1 parent 43d2f5c commit 4021c57

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/ext/h1_reason_phrase.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ impl ReasonPhrase {
5050
Self(Bytes::from_static(reason))
5151
}
5252

53+
// Not public on purpose.
5354
/// Converts a `Bytes` directly into a `ReasonPhrase` without validating.
5455
///
5556
/// Use with care; invalid bytes in a reason phrase can cause serious security problems if
5657
/// emitted in a response.
57-
pub unsafe fn from_bytes_unchecked(reason: Bytes) -> Self {
58+
pub(crate) fn from_bytes_unchecked(reason: Bytes) -> Self {
5859
Self(reason)
5960
}
6061
}

src/proto/h1/role.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ impl Http1Transaction for Client {
10591059
if let Some(reason) = reason {
10601060
// Safety: httparse ensures that only valid reason phrase bytes are present in this
10611061
// field.
1062-
let reason = unsafe { crate::ext::ReasonPhrase::from_bytes_unchecked(reason) };
1062+
let reason = crate::ext::ReasonPhrase::from_bytes_unchecked(reason);
10631063
extensions.insert(reason);
10641064
}
10651065

0 commit comments

Comments
 (0)