@@ -24,8 +24,8 @@ pub(crate) enum InternalRequestError {
2424 InvalidContentType ( String ) ,
2525 /// The Content-Length header could not be parsed as a number
2626 InvalidContentLength ( std:: num:: ParseIntError ) ,
27- /// The Content-Length value exceeds the maximum allowed size
28- ContentLengthTooLarge ( usize ) ,
27+ /// The Content-Length value does not match the actual body length
28+ ContentLengthMismatch { expected : usize , actual : usize } ,
2929}
3030
3131impl From < InternalRequestError > for RequestError {
@@ -44,7 +44,7 @@ impl From<&RequestError> for JsonReply {
4444 MissingHeader ( _)
4545 | InvalidContentType ( _)
4646 | InvalidContentLength ( _)
47- | ContentLengthTooLarge ( _ ) =>
47+ | ContentLengthMismatch { .. } =>
4848 JsonReply :: new ( crate :: error_codes:: ErrorCode :: OriginalPsbtRejected , e) ,
4949 }
5050 }
@@ -57,8 +57,8 @@ impl fmt::Display for RequestError {
5757 InternalRequestError :: InvalidContentType ( content_type) =>
5858 write ! ( f, "Invalid content type: {content_type}" ) ,
5959 InternalRequestError :: InvalidContentLength ( e) => write ! ( f, "{e}" ) ,
60- InternalRequestError :: ContentLengthTooLarge ( length ) =>
61- write ! ( f, "Content length too large: {length }." ) ,
60+ InternalRequestError :: ContentLengthMismatch { expected , actual } =>
61+ write ! ( f, "Content length mismatch: expected {expected}, got {actual }." ) ,
6262 }
6363 }
6464}
@@ -69,7 +69,7 @@ impl error::Error for RequestError {
6969 InternalRequestError :: InvalidContentLength ( e) => Some ( e) ,
7070 InternalRequestError :: MissingHeader ( _) => None ,
7171 InternalRequestError :: InvalidContentType ( _) => None ,
72- InternalRequestError :: ContentLengthTooLarge ( _ ) => None ,
72+ InternalRequestError :: ContentLengthMismatch { .. } => None ,
7373 }
7474 }
7575}
0 commit comments