File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -41,11 +41,22 @@ impl Content {
4141 ///
4242 /// # Errors
4343 /// Returns an error if content is not correctly encoded
44- #[ allow( clippy:: unnecessary_wraps) ]
4544 pub ( crate ) fn from_decoded (
4645 data : Vec < u8 > , content_type : ContentType , content_encoding : Option < ContentEncoding > ,
4746 ) -> anyhow:: Result < Self > {
4847 // TODO add content_type verification
48+ match content_type {
49+ ContentType :: Json => {
50+ if let Err ( e) = serde_json:: from_slice :: < serde_json:: Value > ( & data) {
51+ anyhow:: bail!( "Invalid {content_type} content: {e}" )
52+ }
53+ } ,
54+ ContentType :: Cbor => {
55+ if let Err ( e) = minicbor:: decode :: < minicbor:: data:: Token > ( & data) {
56+ anyhow:: bail!( "Invalid {content_type} content: {e}" )
57+ }
58+ } ,
59+ }
4960 Ok ( Self {
5061 data,
5162 content_type,
You can’t perform that action at this time.
0 commit comments