From 82c290c4d26a13a8c03d2666bb5e3fe23401b161 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:42:07 +0300 Subject: [PATCH] Fix context timeout --- CHANGELOG.md | 6 ++++++ nethttp_request_adapter.go | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e32faf..21864cd 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.1.2] - 2023-01-22 + +### Changed + +- Fix bug passing no timeout in client as 0 timeout in context . + ## [1.1.1] - 2023-11-22 ### Added diff --git a/nethttp_request_adapter.go b/nethttp_request_adapter.go index 7896394..395e427 100644 --- a/nethttp_request_adapter.go +++ b/nethttp_request_adapter.go @@ -215,7 +215,8 @@ func (a *NetHttpRequestAdapter) prepareContext(ctx context.Context, requestInfo ctx = context.Background() } // set deadline if not set in receiving context - if _, deadlineSet := ctx.Deadline(); !deadlineSet { + // ignore if timeout is 0 as it means no timeout + if _, deadlineSet := ctx.Deadline(); !deadlineSet && a.httpClient.Timeout != 0 { ctx, _ = context.WithTimeout(ctx, a.httpClient.Timeout) }