From e6cc2adba44b2c6d6b5a7653dee62531fe1bf349 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:08:26 +0300 Subject: [PATCH] Adds read content value --- CHANGELOG.md | 6 +++++- nethttp_request_adapter.go | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb9bbc3..7e0ad61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -## [1.3.1] - 2024-02-09 +## [1.4.0] - 2024-03-07 ### Added +- Returns an `io.ReadCloser` for streamed responses, allows passing an `io.ReadCloser` to request information. + +## [1.3.1] - 2024-02-09 + ### Changed - Fix bug that resulted in the error "content is empty" being returned instead of HTTP status information if the request returned no content and an unsuccessful status code. diff --git a/nethttp_request_adapter.go b/nethttp_request_adapter.go index c140636..a370146 100644 --- a/nethttp_request_adapter.go +++ b/nethttp_request_adapter.go @@ -278,6 +278,9 @@ func (a *NetHttpRequestAdapter) getRequestFromRequestInformation(ctx context.Con reader := bytes.NewReader(requestInfo.Content) request.Body = NopCloser(reader) } + if requestInfo.ContentReader != nil { + request.Body = requestInfo.ContentReader + } if request.Header == nil { request.Header = make(nethttp.Header) } @@ -575,6 +578,9 @@ func (a *NetHttpRequestAdapter) SendPrimitive(ctx context.Context, requestInfo * } return res, nil } + if typeName == "io.ReadCloser" { + return response.Body, nil + } parseNode, _, err := a.getRootParseNode(ctx, response, span) if err != nil { return nil, err