You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fetch the entire model payload in the pipeline (#3071)
Resolves#2073 by splitting methods on the `Pipeline`:
* `send()` returns a `RawResponse` which is fully buffered in the
`TransportPolicy`.
* `stream()` returns a `BufResponse` which only the initial send goes
through the pipeline e.g., on HTTP 429.
The `stream()` method is basically what `send()` was before, but because
we expect nearly all pipeline requests to fetch the entire response,
we retain `send()` as the primary function.
Copy file name to clipboardExpand all lines: sdk/core/azure_core/CHANGELOG.md
+27-4Lines changed: 27 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,38 @@
5
5
### Features Added
6
6
7
7
- Added `Error::with_error_fn()`.
8
+
- Added `AsyncResponse<T>` for responses that may stream the body outside the HTTP pipeline. This replaces `Response<T, F>` requiring an async read of the body that occurred outside the HTTP pipeline.
9
+
- Added `http::response::BufResponseBody`, which also implements `Stream`.
10
+
- Added a `Pipeline::stream()` to return a `Result<BufResponse>`.
11
+
- Added `RawResponse::deconstruct()`.
12
+
- Added `ResponseBody::collect_string()`.
13
+
- Added `ResponseBody::from_bytes()`.
14
+
- Implemented `AsRef<[u8]>` and `Deref<Target = [u8]>` for `ResponseBody`.
8
15
9
16
### Breaking Changes
10
17
18
+
11
19
- Changed `ClientOptions::retry` from `Option<RetryOptions>` to `RetryOptions`.
12
-
- Changed `RawResponse::json()` from `async` to synchronous function. The body was already buffered.
13
-
- Changed `RawResponse::xml()` from `async` to synchronous function. The body was already buffered.
20
+
- Changed `DeserializeWith::deserialize_with()` to be sync.
21
+
- Changed `Pipeline::send()` to return a `Result<RawResponse>`.
22
+
- Changed `RawResponse::body()` to return a `&ResponseBody` instead of `&Bytes`. `ResponseBody` wraps `&Bytes`, and implements `AsRef<[u8]>` and `Deref<Target = [u8]>`.
23
+
- Changed `RawResponse::into_body()` to return a `ResponseBody` instead of `Bytes`. `ResponseBody` wraps `&Bytes`, and implements `AsRef<[u8]>` and `Deref<Target = [u8]>`.
24
+
- Changed `RawResponse::json()` from `async` to a sync function. The body was already buffered.
25
+
- Changed `RawResponse::xml()` from `async` to a sync function. The body was already buffered.
26
+
- Changed `Response<T, F>` to fully sync; it holds a `RawResponse` that was already buffered entirely from the service so no longer needs or defines async functions.
27
+
- Removed `create_extensible_enum` and `create_enum` macros.
28
+
- Removed `BufResponse::json()`.
29
+
- Removed `BufResponse::xml()`.
30
+
- Removed `CustomHeadersPolicy` from public API.
14
31
- Removed `ErrorKind::http_response()`. Construct an `ErrorResponse::HttpResponse` variant instead.
32
+
- Removed `ExponentialRetryPolicy` from public API.
33
+
- Removed `FixedRetryPolicy` from public API.
34
+
- Removed `LoggingPolicy` from public API.
35
+
- Removed `NoRetryPolicy` from public API.
36
+
- Removed implementation of `Stream` for `ResponseBody`.
15
37
- Removed several unreferenced HTTP headers and accessor structures for those headers.
16
-
- Renamed `TransportOptions` to `Transport`.
17
38
- Renamed `TransportOptions::new_custom_policy()` to `Transport::with_policy()`.
39
+
- Renamed `TransportOptions` to `Transport`.
18
40
- Renamed a number of construction functions for `Error` to align with [guidelines](https://azure.github.io/azure-sdk/rust_introduction.html)"
19
41
- Renamed `Error::full()` to `Error::with_error()`.
20
42
- Renamed `Error::with_message()` to `Error::with_message_fn()`.
@@ -24,7 +46,8 @@
24
46
- Renamed `ResultExt::map_kind()` to `ResultExt::with_kind()`.
25
47
- Renamed `ResultExt::with_context()` to `ResultExt::with_context_fn()`.
26
48
- Renamed `ResultExt::context()` to `ResultExt::with_context()`.
27
-
- Removed `create_extensible_enum` and `create_enum` macros.
49
+
- Replaced implementation of `From<BufResponse>` for `Response<T, F>` to `From<RawResponse>`.
50
+
- Replaced implementation of `From<Response<T, F>>` for `BufResponse` to `From<AsyncResponse<T>>`.
/// * `Err(Error)` if the response is an error, with details extracted from the response
129
164
/// body if possible.
130
165
///
131
-
pubasyncfncheck_success(
132
-
response:BufResponse,
166
+
pubasyncfncheck_success<T:Response>(
167
+
response:T,
133
168
options:Option<CheckSuccessOptions>,
134
-
) -> crate::Result<BufResponse>{
169
+
) -> crate::Result<T>{
135
170
let status = response.status();
136
171
137
172
if options
@@ -438,9 +473,10 @@ mod tests {
438
473
Bytes::from_static(br#"{"error":{"code":"InvalidRequest","message":"The request object is not recognized.","innererror":{"code":"InvalidKey"},"key":"foo"}}"#),
439
474
);
440
475
let error_response:ErrorResponse = buf_response
476
+
.try_into_raw_response()
477
+
.await?
441
478
.into_body()
442
479
.json()
443
-
.await
444
480
.expect("expected an ErrorResponse");
445
481
error_response.error.as_ref().expect("error should be set");
0 commit comments