@@ -15,11 +15,10 @@ use deno_core::url::Url;
1515use deno_error:: JsError ;
1616use deno_error:: JsErrorBox ;
1717use deno_lib:: version:: DENO_VERSION_INFO ;
18- use deno_runtime:: deno_fetch;
19- use deno_runtime:: deno_fetch:: CreateHttpClientOptions ;
20- use deno_runtime:: deno_fetch:: ResBody ;
21- use deno_runtime:: deno_fetch:: create_http_client;
2218use deno_runtime:: deno_tls:: RootCertStoreProvider ;
19+ use deno_web:: fetch:: CreateHttpClientOptions ;
20+ use deno_web:: fetch:: ResBody ;
21+ use deno_web:: fetch:: create_http_client;
2322use http:: HeaderMap ;
2423use http:: StatusCode ;
2524use http:: header:: CONTENT_LENGTH ;
@@ -33,7 +32,7 @@ use crate::util::progress_bar::UpdateGuard;
3332#[ derive( Debug , Error ) ]
3433pub enum SendError {
3534 #[ error( transparent) ]
36- Send ( #[ from] deno_fetch :: ClientSendError ) ,
35+ Send ( #[ from] deno_web :: fetch :: ClientSendError ) ,
3736 #[ error( transparent) ]
3837 InvalidUri ( #[ from] http:: uri:: InvalidUri ) ,
3938}
@@ -44,7 +43,7 @@ pub struct HttpClientProvider {
4443 // it's not safe to share a reqwest::Client across tokio runtimes,
4544 // so we store these Clients keyed by thread id
4645 // https://github.com/seanmonstar/reqwest/issues/1148#issuecomment-910868788
47- clients_by_thread_id : Mutex < HashMap < ThreadId , deno_fetch :: Client > > ,
46+ clients_by_thread_id : Mutex < HashMap < ThreadId , deno_web :: fetch :: Client > > ,
4847}
4948
5049impl std:: fmt:: Debug for HttpClientProvider {
@@ -111,7 +110,7 @@ pub struct DownloadError(pub Box<DownloadErrorKind>);
111110pub enum DownloadErrorKind {
112111 #[ class( inherit) ]
113112 #[ error( transparent) ]
114- Fetch ( deno_fetch :: ClientSendError ) ,
113+ Fetch ( deno_web :: fetch :: ClientSendError ) ,
115114 #[ class( inherit) ]
116115 #[ error( transparent) ]
117116 UrlParse ( #[ from] deno_core:: url:: ParseError ) ,
@@ -178,7 +177,7 @@ impl HttpClientResponse {
178177
179178#[ derive( Debug ) ]
180179pub struct HttpClient {
181- client : deno_fetch :: Client ,
180+ client : deno_web :: fetch :: Client ,
182181 // don't allow sending this across threads because then
183182 // it might be shared accidentally across tokio runtimes
184183 // which will cause issues
@@ -189,15 +188,15 @@ pub struct HttpClient {
189188impl HttpClient {
190189 // DO NOT make this public. You should always be creating one of these from
191190 // the HttpClientProvider
192- fn new ( client : deno_fetch :: Client ) -> Self {
191+ fn new ( client : deno_web :: fetch :: Client ) -> Self {
193192 Self {
194193 client,
195194 _unsend_marker : deno_core:: unsync:: UnsendMarker :: default ( ) ,
196195 }
197196 }
198197
199198 pub fn get ( & self , url : Url ) -> Result < RequestBuilder , http:: Error > {
200- let body = deno_fetch :: ReqBody :: empty ( ) ;
199+ let body = deno_web :: fetch :: ReqBody :: empty ( ) ;
201200 let mut req = http:: Request :: new ( body) ;
202201 * req. uri_mut ( ) = url. as_str ( ) . parse ( ) ?;
203202 Ok ( RequestBuilder {
@@ -209,7 +208,7 @@ impl HttpClient {
209208 pub fn post (
210209 & self ,
211210 url : Url ,
212- body : deno_fetch :: ReqBody ,
211+ body : deno_web :: fetch :: ReqBody ,
213212 ) -> Result < RequestBuilder , http:: Error > {
214213 let mut req = http:: Request :: new ( body) ;
215214 * req. method_mut ( ) = http:: Method :: POST ;
@@ -229,7 +228,7 @@ impl HttpClient {
229228 S : serde:: Serialize ,
230229 {
231230 let json = deno_core:: serde_json:: to_vec ( ser) ?;
232- let body = deno_fetch :: ReqBody :: full ( json. into ( ) ) ;
231+ let body = deno_web :: fetch :: ReqBody :: full ( json. into ( ) ) ;
233232 let builder = self . post ( url, body) ?;
234233 Ok ( builder. header (
235234 http:: header:: CONTENT_TYPE ,
@@ -242,7 +241,7 @@ impl HttpClient {
242241 url : & Url ,
243242 headers : HeaderMap ,
244243 ) -> Result < http:: Response < ResBody > , SendError > {
245- let body = deno_fetch :: ReqBody :: empty ( ) ;
244+ let body = deno_web :: fetch :: ReqBody :: empty ( ) ;
246245 let mut request = http:: Request :: new ( body) ;
247246 * request. uri_mut ( ) = http:: Uri :: try_from ( url. as_str ( ) ) ?;
248247 * request. headers_mut ( ) = headers;
@@ -328,7 +327,8 @@ impl HttpClient {
328327 & self ,
329328 mut url : Url ,
330329 headers : & HeaderMap < HeaderValue > ,
331- ) -> Result < ( http:: Response < deno_fetch:: ResBody > , Url ) , DownloadError > {
330+ ) -> Result < ( http:: Response < deno_web:: fetch:: ResBody > , Url ) , DownloadError >
331+ {
332332 let mut req = self . get ( url. clone ( ) ) ?. build ( ) ;
333333 * req. headers_mut ( ) = headers. clone ( ) ;
334334 let mut response = self
@@ -372,7 +372,7 @@ impl HttpClient {
372372}
373373
374374pub async fn get_response_body_with_progress (
375- response : http:: Response < deno_fetch :: ResBody > ,
375+ response : http:: Response < deno_web :: fetch :: ResBody > ,
376376 progress_guard : Option < & UpdateGuard > ,
377377) -> Result < ( HeaderMap , Vec < u8 > ) , JsErrorBox > {
378378 use http_body:: Body as _;
@@ -440,8 +440,8 @@ where
440440}
441441
442442pub struct RequestBuilder {
443- client : deno_fetch :: Client ,
444- req : http:: Request < deno_fetch :: ReqBody > ,
443+ client : deno_web :: fetch :: Client ,
444+ req : http:: Request < deno_web :: fetch :: ReqBody > ,
445445}
446446
447447impl RequestBuilder {
@@ -452,11 +452,11 @@ impl RequestBuilder {
452452
453453 pub async fn send (
454454 self ,
455- ) -> Result < http:: Response < deno_fetch :: ResBody > , AnyError > {
455+ ) -> Result < http:: Response < deno_web :: fetch :: ResBody > , AnyError > {
456456 self . client . send ( self . req ) . await . map_err ( Into :: into)
457457 }
458458
459- pub fn build ( self ) -> http:: Request < deno_fetch :: ReqBody > {
459+ pub fn build ( self ) -> http:: Request < deno_web :: fetch :: ReqBody > {
460460 self . req
461461 }
462462}
0 commit comments