diff --git a/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/Products/ProductsIntegrationTests.cs b/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/Products/ProductsIntegrationTests.cs index 1e8497ffd0f..f1172e3b039 100644 --- a/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/Products/ProductsIntegrationTests.cs +++ b/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/Products/ProductsIntegrationTests.cs @@ -51,7 +51,7 @@ await Assert.ThrowsAsync(async () => }); }); } - + [Fact] public async Task HeadNotFoundReturnsDefault() { @@ -76,7 +76,7 @@ await Assert.ThrowsAsync(async () => { await apiRoot.Products().WithKey(product.Key + "-unknown").Get().ExecuteAsync(); }); - + var sendProduct = await apiRoot.Products().WithKey(product.Key).Get().SendAsync(); Assert.True(sendProduct.IsSuccess()); Assert.Equal(HttpStatusCode.OK, sendProduct.StatusCode); @@ -96,14 +96,14 @@ await Assert.ThrowsAsync(async () => Assert.True(sendHead.IsSuccess()); Assert.Equal(HttpStatusCode.OK, sendHead.StatusCode); Assert.Equal("", sendHead.Body); - + var sendUnknownHead = await apiRoot.Products().WithKey(product.Key + "-unknown").Head().SendAsync(); Assert.False(sendUnknownHead.IsSuccess()); Assert.Equal(HttpStatusCode.NotFound, sendUnknownHead.StatusCode); Assert.Equal("", sendUnknownHead.Body); }); } - + [Fact] public async Task NotFoundReturnsDefault() { @@ -147,7 +147,7 @@ await WithProduct(apiRoot, async product => Assert.True(sendHead.IsSuccess()); Assert.Equal(HttpStatusCode.OK, sendHead.StatusCode); Assert.Equal("", sendHead.Body); - + var sendUnknownHead = await apiRoot.Products().WithKey(product.Key + "-unknown").Head().SendAsync(); Assert.False(sendUnknownHead.IsSuccess()); Assert.Equal(HttpStatusCode.NotFound, sendUnknownHead.StatusCode); diff --git a/commercetools.Sdk/commercetools.Base.Client/ClientOptions.cs b/commercetools.Sdk/commercetools.Base.Client/ClientOptions.cs index 9079101b700..e653ac1d7e7 100644 --- a/commercetools.Sdk/commercetools.Base.Client/ClientOptions.cs +++ b/commercetools.Sdk/commercetools.Base.Client/ClientOptions.cs @@ -9,7 +9,7 @@ public class ClientOptions DecompressionMethods.Deflate | DecompressionMethods.GZip; public bool ReadResponseAsStream { get; set; } = true; - + public bool NotFoundReturnsDefault { get; set; } = false; public bool HeadNotFoundReturnsDefault { get; set; } = false; diff --git a/commercetools.Sdk/commercetools.Base.Client/ErrorHandler.cs b/commercetools.Sdk/commercetools.Base.Client/ErrorHandler.cs index 18d6b2c7273..c84b96291f1 100644 --- a/commercetools.Sdk/commercetools.Base.Client/ErrorHandler.cs +++ b/commercetools.Sdk/commercetools.Base.Client/ErrorHandler.cs @@ -27,7 +27,7 @@ protected override async Task SendAsync(HttpRequestMessage if (response is { IsSuccessStatusCode: true }) return response; - if (response.StatusCode == HttpStatusCode.NotFound && (_notFoundReturnsEmpty || (_headNotFoundReturnsEmpty && request.Method == HttpMethod.Head) )) + if (response.StatusCode == HttpStatusCode.NotFound && (_notFoundReturnsEmpty || (_headNotFoundReturnsEmpty && request.Method == HttpMethod.Head))) { response.Content = new EmptyContent(); return response; diff --git a/reference.txt b/reference.txt new file mode 100644 index 00000000000..a0cea82f094 --- /dev/null +++ b/reference.txt @@ -0,0 +1 @@ +cae10cdd02689459b68469d567db1eacc1e4f60e diff --git a/references.txt b/references.txt index 76d2a085831..c665c4f9e4c 100644 --- a/references.txt +++ b/references.txt @@ -310,3 +310,4 @@ e3d5bc9cb69146c5d1dd755ed5e8cf2f54566b3a f28a1461a4122eed74c423156f1969ba204e6948 e18cd8073ea975fe92c1bad4dea957b16ee0b1c4 bfbd1780852675d9974bf71bea4afff569a4cc00 +ad99469046af42aaf1e65fe1a82a2188ba6a3a3f