1
- use std:: str:: FromStr ;
2
-
3
1
use crate :: {
4
- api:: { route:: RouteUrl , v0alpha1, v0alpha2, StatusCode } ,
2
+ api:: { route:: RouteUrl , v0alpha1, v0alpha2} ,
3
+ authority:: { generate_capability, Author , SphereAbility , SphereReference } ,
4
+ data:: { Link , MemoIpld } ,
5
5
error:: NoosphereError ,
6
6
stream:: { from_car_stream, memo_history_stream, put_block_stream, to_car_stream} ,
7
7
} ;
8
8
use anyhow:: { anyhow, Result } ;
9
9
use async_stream:: try_stream;
10
10
use bytes:: Bytes ;
11
11
use cid:: Cid ;
12
+ use http:: StatusCode ;
12
13
use iroh_car:: CarReader ;
13
14
use libipld_cbor:: DagCborCodec ;
14
15
use noosphere_common:: { ConditionalSend , ConditionalSync , UnsharedStream } ;
15
-
16
- use crate :: {
17
- authority:: { generate_capability, Author , SphereAbility , SphereReference } ,
18
- data:: { Link , MemoIpld } ,
19
- } ;
20
16
use noosphere_storage:: { block_deserialize, block_serialize, BlockStore } ;
21
17
use noosphere_ucan:: {
22
18
builder:: UcanBuilder ,
@@ -26,6 +22,7 @@ use noosphere_ucan::{
26
22
ucan:: Ucan ,
27
23
} ;
28
24
use reqwest:: header:: HeaderMap ;
25
+ use std:: str:: FromStr ;
29
26
use tokio_stream:: { Stream , StreamExt } ;
30
27
use tokio_util:: io:: StreamReader ;
31
28
use url:: Url ;
93
90
client. get ( url) . send ( ) . await ?
94
91
} ;
95
92
96
- match translate_status_code ( did_response. status ( ) ) ? {
93
+ match did_response. status ( ) {
97
94
StatusCode :: OK => ( ) ,
98
95
_ => return Err ( anyhow ! ( "Unable to look up gateway identity" ) ) ,
99
96
} ;
@@ -475,7 +472,7 @@ where
475
472
v0alpha2:: PushError :: BrokenUpstream
476
473
} ) ?;
477
474
478
- let status = translate_status_code ( response. status ( ) ) ? ;
475
+ let status = response. status ( ) ;
479
476
trace ! ( "Checking response ({})..." , status) ;
480
477
481
478
if status == StatusCode :: CONFLICT {
@@ -531,22 +528,3 @@ where
531
528
Ok ( push_response)
532
529
}
533
530
}
534
-
535
- /// Both `reqwest` and `axum` re-export `StatusCode` from the `http` crate.
536
- ///
537
- /// We're stuck on [email protected] [1] that uses an older version
538
- /// of `http::StatusCode`, whereas axum >= 0.7 uses the 1.0 release
539
- /// of several HTTP libraries (`http`, `http-body`, `hyper`) [2], which
540
- /// we'd like to use as our canonical representation.
541
- ///
542
- /// This utility converts between the old `reqwest::StatusCode` to the
543
- /// >=1.0 implementation. Notably, we do not pull in all of `axum`
544
- /// into the `noosphere-core` crate, only the common underlying
545
- /// crate `[email protected] ` (or greater).
546
- ///
547
- /// [1] https://github.com/subconsciousnetwork/noosphere/issues/686
548
- /// [2] https://github.com/tokio-rs/axum/blob/5b6204168a676497d2f4188af603546d9ebfe20a/axum/CHANGELOG.md#070-27-november-2023
549
- fn translate_status_code ( reqwest_code : reqwest:: StatusCode ) -> Result < StatusCode > {
550
- let code: u16 = reqwest_code. into ( ) ;
551
- Ok ( code. try_into ( ) ?)
552
- }
0 commit comments