-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed as not planned
Labels
Azure.Coreazure-coreazure-coreClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.needs-team-triageWorkflow: This issue needs the team to triage.Workflow: This issue needs the team to triage.
Description
boolean HttpResponse.isBuffered()method? It'd allow to optimize stuff here and in HttpResponseLogger- something like
HttpResponse.addCloseHook(BiSupplier<HttpResponse, Throwable> hook)- this would help us avoid wrapping streams
Not strictly related, but I think
BinaryDatashould also haveisBufferedorisBufferableandcloseto optimize/allow more control to close streams under (e.g. when I don't want to read full content)
Originally posted by @lmolkova in #38013 (comment)
Use cases:
- Logging: when we log response body, we want to know when response body has been received. Today we have to wrap
HttpResponseobject intoLoggingHttpResponseto achieve it - Tracing: the same
- HttpClients sending request body: can safely do
BinaryData.toBytes()is content is already buffered. Today they have to switch over all content implementations. We had some cases in the past where we forgot to update all the places when we added new content types.
Before:
Lines 170 to 177 in 3a1a3c8
| BinaryDataContent content = BinaryDataHelper.getContent(bodyContent); | |
| if (content instanceof ByteArrayContent | |
| || content instanceof StringContent | |
| || content instanceof SerializableContent | |
| || content instanceof ByteBufferContent) { | |
| return RequestBody.create(content.toBytes(), mediaType); | |
| } else { |
After
if (bodyContent.isBuffered()) {
return RequestBody.create(content.toBytes(), mediaType);
} else {In logging/tracing:
Before
return next.process()
.doOnSuccess(response -> updateSpan(response, span))
.map(response -> new TraceableResponse(response, span))After:
return next.process()
.doOnSuccess(response -> updateSpan(response, span))
.map(response -> {
if (response.isBuffered()) {
endSpan(span);
return response;
}
return new TraceableResponse(response, span);
})Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Azure.Coreazure-coreazure-coreClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.needs-team-triageWorkflow: This issue needs the team to triage.Workflow: This issue needs the team to triage.
Type
Projects
Status
Done