From 9d3829ddcc5fd9fb78320f34c1a71704240c8b42 Mon Sep 17 00:00:00 2001 From: Yangjing Zhang Date: Thu, 9 May 2024 10:27:26 +0800 Subject: [PATCH 1/3] Allow custom response handlers to return nil result values Maintain consistent behavior with the default handler by returning nil for HTTP responses with a status code of 204 or empty body. --- nethttp_request_adapter.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nethttp_request_adapter.go b/nethttp_request_adapter.go index c140636..6a9b48d 100644 --- a/nethttp_request_adapter.go +++ b/nethttp_request_adapter.go @@ -337,6 +337,9 @@ func (a *NetHttpRequestAdapter) Send(ctx context.Context, requestInfo *abs.Reque span.RecordError(err) return nil, err } + if result == nil { + return nil, nil + } return result.(absser.Parsable), nil } else if response != nil { defer a.purge(response) From 9dc08395c3fb089c30ca249f5ec06c30063083aa Mon Sep 17 00:00:00 2001 From: Yangjing Zhang Date: Thu, 9 May 2024 22:52:27 +0800 Subject: [PATCH 2/3] more fixes --- nethttp_request_adapter.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nethttp_request_adapter.go b/nethttp_request_adapter.go index 6a9b48d..243483d 100644 --- a/nethttp_request_adapter.go +++ b/nethttp_request_adapter.go @@ -397,6 +397,9 @@ func (a *NetHttpRequestAdapter) SendEnum(ctx context.Context, requestInfo *abs.R span.RecordError(err) return nil, err } + if result == nil { + return nil, nil + } return result.(absser.Parsable), nil } else if response != nil { defer a.purge(response) @@ -448,6 +451,9 @@ func (a *NetHttpRequestAdapter) SendCollection(ctx context.Context, requestInfo span.RecordError(err) return nil, err } + if result == nil { + return nil, nil + } return result.([]absser.Parsable), nil } else if response != nil { defer a.purge(response) @@ -499,6 +505,9 @@ func (a *NetHttpRequestAdapter) SendEnumCollection(ctx context.Context, requestI span.RecordError(err) return nil, err } + if result == nil { + return nil, nil + } return result.([]any), nil } else if response != nil { defer a.purge(response) @@ -558,6 +567,9 @@ func (a *NetHttpRequestAdapter) SendPrimitive(ctx context.Context, requestInfo * span.RecordError(err) return nil, err } + if result == nil { + return nil, nil + } return result.(absser.Parsable), nil } else if response != nil { defer a.purge(response) @@ -639,6 +651,9 @@ func (a *NetHttpRequestAdapter) SendPrimitiveCollection(ctx context.Context, req span.RecordError(err) return nil, err } + if result == nil { + return nil, nil + } return result.([]any), nil } else if response != nil { defer a.purge(response) From 7578f1ab88b382103d5b7e80bc0e4377597530f9 Mon Sep 17 00:00:00 2001 From: Yangjing Zhang Date: Thu, 9 May 2024 23:02:30 +0800 Subject: [PATCH 3/3] Added changelog entry and bumped version to 1.3.4 --- CHANGELOG.md | 6 ++++++ user_agent_handler.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da2b6b6..e86a462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +## [1.3.4] - 2024-05-09 + +### Changed + +- Allow custom response handlers to return nil result values. + ## [1.3.3] - 2024-03-19 - Fix bug where overriding http.DefaultTransport with an implementation other than http.Transport would result in an interface conversion panic diff --git a/user_agent_handler.go b/user_agent_handler.go index c984b8e..2ebc657 100644 --- a/user_agent_handler.go +++ b/user_agent_handler.go @@ -42,7 +42,7 @@ func NewUserAgentHandlerOptions() *UserAgentHandlerOptions { return &UserAgentHandlerOptions{ Enabled: true, ProductName: "kiota-go", - ProductVersion: "1.3.3", + ProductVersion: "1.3.4", } }