File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
src/main/java/com/microsoft/graph/core/requests/upload Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,11 @@ public <T extends Parsable> UploadResult<T> handleResponse(@Nonnull final Respon
5353 Objects .requireNonNull (factory );
5454 try (final ResponseBody body = response .body ()) {
5555 UploadResult <T > uploadResult = new UploadResult <>();
56- if (Objects .isNull (body )) {
56+ String contentLengthHeader = response .headers ().get ("content-length" );
57+ if (Objects .isNull (body )
58+ || Objects .isNull (body .contentType ())
59+ || (!Objects .isNull (contentLengthHeader ) && Integer .parseInt (contentLengthHeader ) == 0 )
60+ ) {
5761 if (response .code () == HttpURLConnection .HTTP_CREATED ) {
5862 final String location = response .headers ().get ("location" );
5963 if (!Objects .isNull (location ) && !location .isEmpty ()) {
@@ -71,8 +75,7 @@ public <T extends Parsable> UploadResult<T> handleResponse(@Nonnull final Respon
7175 .withResponseHeaders (HeadersCompatibility .getResponseHeaders (response .headers ()))
7276 .build ();
7377 }
74- String contentLengthHeader = response .headers ().get ("content-length" );
75- boolean canBeParsed = (!Objects .isNull (contentLengthHeader ) && Integer .valueOf (contentLengthHeader ) > 0 ) || !Objects .isNull (body .contentType ());
78+ boolean canBeParsed = (!Objects .isNull (contentLengthHeader ) && Integer .parseInt (contentLengthHeader ) > 0 ) || !Objects .isNull (body .contentType ());
7679 String contentType = canBeParsed ? body .contentType ().toString ().split (";" )[0 ] : null ; //contentType.toString() returns in format <mediaType>;<charset>, we only want the mediaType.
7780 if (canBeParsed ) {
7881 final ParseNode parseNode = parseNodeFactory .getParseNode (contentType , in );
You can’t perform that action at this time.
0 commit comments