@@ -3711,26 +3711,25 @@ impl Store {
3711
3711
#[ cfg( all( feature = "fetch_remote_manifests" , not( target_os = "wasi" ) ) ) ]
3712
3712
fn fetch_remote_manifest ( url : & str ) -> Result < Vec < u8 > > {
3713
3713
use conv:: ValueFrom ;
3714
- use ureq:: Error as uError;
3715
3714
3716
3715
//const MANIFEST_CONTENT_TYPE: &str = "application/x-c2pa-manifest-store"; // todo verify once these are served
3717
3716
const DEFAULT_MANIFEST_RESPONSE_SIZE : usize = 10 * 1024 * 1024 ; // 10 MB
3718
3717
3719
3718
match ureq:: get ( url) . call ( ) {
3720
3719
Ok ( response) => {
3721
3720
if response. status ( ) == 200 {
3722
- let len = response
3723
- . header ( "Content-Length" )
3724
- . and_then ( |s| s. parse :: < usize > ( ) . ok ( ) )
3721
+ let body = response. into_body ( ) ;
3722
+ let len = body
3723
+ . content_length ( )
3724
+ . and_then ( |content_length| content_length. try_into ( ) . ok ( ) )
3725
3725
. unwrap_or ( DEFAULT_MANIFEST_RESPONSE_SIZE ) ; // todo figure out good max to accept
3726
3726
3727
3727
let mut response_bytes: Vec < u8 > = Vec :: with_capacity ( len) ;
3728
3728
3729
3729
let len64 = u64:: value_from ( len)
3730
3730
. map_err ( |_err| Error :: BadParam ( "value out of range" . to_string ( ) ) ) ?;
3731
3731
3732
- response
3733
- . into_reader ( )
3732
+ body. into_reader ( )
3734
3733
. take ( len64)
3735
3734
. read_to_end ( & mut response_bytes)
3736
3735
. map_err ( |_err| {
@@ -3741,17 +3740,12 @@ impl Store {
3741
3740
} else {
3742
3741
Err ( Error :: RemoteManifestFetch ( format ! (
3743
3742
"fetch failed: code: {}, status: {}" ,
3744
- response. status( ) ,
3745
- response. status_text ( )
3743
+ response. status( ) . as_u16 ( ) ,
3744
+ response. status ( ) . as_str ( )
3746
3745
) ) )
3747
3746
}
3748
3747
}
3749
- Err ( uError:: Status ( code, resp) ) => Err ( Error :: RemoteManifestFetch ( format ! (
3750
- "code: {}, response: {}" ,
3751
- code,
3752
- resp. status_text( )
3753
- ) ) ) ,
3754
- Err ( uError:: Transport ( _) ) => Err ( Error :: RemoteManifestFetch ( url. to_string ( ) ) ) ,
3748
+ Err ( err) => Err ( Error :: RemoteManifestFetch ( err. to_string ( ) ) ) ,
3755
3749
}
3756
3750
}
3757
3751
0 commit comments