Return response not exception.
MODIFY
XRayBuilder.Core/src/Libraries/Http/HttpClient.cs
XRayBuilder.Core/src/Libraries/Http/HttpClient.cs
@@ -228,14 +228,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
try
{
var response = await base.SendAsync(request, cancellationToken);
- if (!response.IsSuccessStatusCode)
- throw new HttpClientException(response.StatusCode.ToString())
- {
- Response = response
- };
- return response;
- }
- catch (HttpClientException ex) when (ex.Response.StatusCode == HttpStatusCode.NotFound
+ if (!response.IsSuccessStatusCode
&& request.RequestUri.Host.Contains(".amazon.")
&& !request.RequestUri.Host.EndsWith(".com"))
{
@@ -245,12 +238,18 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
Host = "www.amazon.com"
};
request.RequestUri = builder.Uri;
- var response = await base.SendAsync(request, cancellationToken);
+ response = await base.SendAsync(request, cancellationToken);
if (response.StatusCode == HttpStatusCode.NotFound)
return response;
Logger?.Log($"Not available from {originalHost}, but found on Amazon.com ({request.RequestUri})");
return response;
}
+ return response;
+ }
+ catch (HttpClientException)
+ {
+ return new HttpResponseMessage();
+ }
}
}

Return response not exception.