Skip to content

Commit 158f3c6

Browse files
Microsoft Graph DevX ToolingMicrosoft Graph DevX Tooling
authored andcommitted
fix: Ensure 3XX responses without location header do not throw
1 parent bca88f5 commit 158f3c6

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -644,15 +644,7 @@ private Response throwIfFailedResponse(
644644
final int statusCode = response.code();
645645
final ResponseHeaders responseHeaders =
646646
HeadersCompatibility.getResponseHeaders(response.headers());
647-
if (statusCode >= 300 && statusCode < 400) {
648-
649-
if (responseHeaders.get("Location") != null) {
650-
spanForAttributes.setAttribute("Location", true);
651-
return response;
652-
}
653-
spanForAttributes.setAttribute(errorMappingFoundAttributeName, false);
654-
return null;
655-
}
647+
if (statusCode >= 300 && statusCode < 400) return response;
656648
if (errorMappings == null
657649
|| !errorMappings.containsKey(statusCodeAsString)
658650
&& !(statusCode >= 400

components/http/okHttp/src/test/java/com/microsoft/kiota/http/OkHttpRequestAdapterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ void loggingInterceptorDoesNotDrainRequestBodyForNonMarkableStreams() throws Exc
530530
var mockEntity = creatMockEntity();
531531
requestAdapter.send(requestInformation, null, node -> mockEntity);
532532
var nativeResponse = (Response) nativeResponseHandler.getValue();
533-
assertNotNull(nativeResponse);
533+
assertNull(nativeResponse);
534534
assertEquals(contentLength, nativeResponse.body().source().readByteArray().length);
535535
}
536536
}

0 commit comments

Comments
 (0)