File tree Expand file tree Collapse file tree 2 files changed +33
-11
lines changed Expand file tree Collapse file tree 2 files changed +33
-11
lines changed Original file line number Diff line number Diff line change @@ -177,15 +177,13 @@ impl WasiSleep {
177
177
}
178
178
179
179
impl AsyncSleep for WasiSleep {
180
- #[ allow( clippy:: missing_transmute_annotations) ]
181
180
fn sleep ( & self , duration : std:: time:: Duration ) -> Sleep {
182
181
let reactor = self . reactor . clone ( ) ;
183
-
184
182
let fut = async move {
185
183
let nanos = duration. as_nanos ( ) as u64 ;
186
184
let pollable = monotonic_clock:: subscribe_duration ( nanos) ;
187
185
188
- reactor. clone ( ) . wait_for ( pollable) . await ;
186
+ reactor. wait_for ( pollable) . await ;
189
187
} ;
190
188
Sleep :: new ( Box :: pin ( UnsafeFuture :: new ( fut) ) )
191
189
}
Original file line number Diff line number Diff line change 1
- use std:: { str:: FromStr , sync:: Arc } ;
1
+ use std:: { io :: Read , str:: FromStr , sync:: Arc } ;
2
2
3
3
use aws_sdk_bedrockruntime:: { config, error:: ConnectorError } ;
4
4
use aws_smithy_runtime_api:: {
@@ -82,13 +82,10 @@ impl WasiConnector {
82
82
) ;
83
83
}
84
84
85
- let mut request = self . 0 . request ( method, url) . headers ( header_map) ;
86
-
87
- if let Some ( bytes) = parts. body . bytes ( ) {
88
- request = request. body ( bytes. to_owned ( ) ) ;
89
- }
90
-
91
- request
85
+ self . 0
86
+ . request ( method, url)
87
+ . headers ( header_map)
88
+ . body ( reqwest:: Body :: new :: < BodyReader > ( parts. body . into ( ) ) )
92
89
. send ( )
93
90
. await
94
91
. map_err ( |e| ConnectorError :: other ( e. into ( ) , None ) )
@@ -138,3 +135,30 @@ impl HttpConnector for SharedWasiConnector {
138
135
HttpConnectorFuture :: new ( UnsafeFuture :: new ( future) )
139
136
}
140
137
}
138
+
139
+ struct BodyReader {
140
+ body : SdkBody ,
141
+ }
142
+
143
+ impl From < SdkBody > for BodyReader {
144
+ fn from ( value : SdkBody ) -> Self {
145
+ Self :: new ( value)
146
+ }
147
+ }
148
+
149
+ impl BodyReader {
150
+ fn new ( body : SdkBody ) -> Self {
151
+ Self { body }
152
+ }
153
+ }
154
+
155
+ impl Read for BodyReader {
156
+ fn read ( & mut self , buf : & mut [ u8 ] ) -> std:: io:: Result < usize > {
157
+ let bytes = self . body . bytes ( ) ;
158
+
159
+ match bytes {
160
+ Some ( mut bytes) => bytes. read ( buf) ,
161
+ None => Ok ( 0 ) ,
162
+ }
163
+ }
164
+ }
You can’t perform that action at this time.
0 commit comments