@@ -422,29 +422,24 @@ private Response processRequestV2(final NextcloudRequest request, final InputStr
422422 client .setFollowRedirects (request .isFollowRedirects ());
423423 int status = client .executeMethod (method );
424424
425- // handle “Not Modified” responses
426- if (status == 304 ) {
427- Log_OC .i (TAG , "Received status " + status + " not modified" );
428- method .releaseConnection ();
429- return new Response ();
430- }
431-
425+ // Check if status code is 2xx --> https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_Success
432426 if (status >= HTTP_STATUS_CODE_OK && status < HTTP_STATUS_CODE_MULTIPLE_CHOICES ) {
433427 return new Response (method );
434- }
428+ } else {
429+ InputStream inputStream = method .getResponseBodyAsStream ();
430+ String total = "No response body" ;
435431
436- InputStream inputStream = method .getResponseBodyAsStream ();
437- String total = "No response body" ;
432+ // If response body is available
433+ if (inputStream != null ) {
434+ total = inputStreamToString (inputStream );
435+ Log_OC .e (TAG , total );
436+ }
438437
439- if (inputStream != null ) {
440- total = inputStreamToString (inputStream );
441- Log_OC .e (TAG , total );
438+ method .releaseConnection ();
439+ throw new IllegalStateException (EXCEPTION_HTTP_REQUEST_FAILED ,
440+ new IllegalStateException (String .valueOf (status ),
441+ new IllegalStateException (total )));
442442 }
443-
444- method .releaseConnection ();
445- throw new IllegalStateException (EXCEPTION_HTTP_REQUEST_FAILED ,
446- new IllegalStateException (String .valueOf (status ),
447- new IllegalStateException (total )));
448443 }
449444
450445 private boolean isValid (NextcloudRequest request ) {
0 commit comments