Skip to content

Commit 3c71340

Browse files
glebpomseanmonstar
authored andcommitted
feat: add HeaderMap::try_ methods to handle capacity overflow
1 parent 63102bc commit 3c71340

File tree

6 files changed

+498
-151
lines changed

6 files changed

+498
-151
lines changed

src/error.rs

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::fmt;
33
use std::result;
44

55
use crate::header;
6+
use crate::header::MaxSizeReached;
67
use crate::method;
78
use crate::status;
89
use crate::uri;
@@ -27,6 +28,7 @@ enum ErrorKind {
2728
UriParts(uri::InvalidUriParts),
2829
HeaderName(header::InvalidHeaderName),
2930
HeaderValue(header::InvalidHeaderValue),
31+
MaxSizeReached(MaxSizeReached),
3032
}
3133

3234
impl fmt::Debug for Error {
@@ -61,6 +63,7 @@ impl Error {
6163
UriParts(ref e) => e,
6264
HeaderName(ref e) => e,
6365
HeaderValue(ref e) => e,
66+
MaxSizeReached(ref e) => e,
6467
}
6568
}
6669
}
@@ -73,6 +76,14 @@ impl error::Error for Error {
7376
}
7477
}
7578

79+
impl From<MaxSizeReached> for Error {
80+
fn from(err: MaxSizeReached) -> Error {
81+
Error {
82+
inner: ErrorKind::MaxSizeReached(err),
83+
}
84+
}
85+
}
86+
7687
impl From<status::InvalidStatusCode> for Error {
7788
fn from(err: status::InvalidStatusCode) -> Error {
7889
Error {

0 commit comments

Comments
 (0)