mirror of
https://github.com/nextcloud/android.git
synced 2024-11-28 10:18:59 +03:00
Merge pull request #8385 from nextcloud/fix-is-internet-walled-check
Fix ConnectivityService.isInternetWalled() check when content length is -1
This commit is contained in:
commit
3c6415147b
2 changed files with 8 additions and 1 deletions
|
@ -74,7 +74,8 @@ class ConnectivityServiceImpl implements ConnectivityService {
|
|||
|
||||
int status = get.execute(client);
|
||||
|
||||
boolean result = !(status == HttpStatus.SC_NO_CONTENT && get.getResponseContentLength() == 0);
|
||||
// Content-Length is not available when using chunked transfer encoding, so check for -1 as well
|
||||
boolean result = !(status == HttpStatus.SC_NO_CONTENT && get.getResponseContentLength() <= 0);
|
||||
|
||||
get.releaseConnection();
|
||||
|
||||
|
|
|
@ -276,6 +276,12 @@ class ConnectivityServiceTest {
|
|||
assertFalse(connectivityService.isInternetWalled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `status 204 and no content length means internet is not walled`() {
|
||||
mockResponse(contentLength = -1, status = HttpStatus.SC_NO_CONTENT)
|
||||
assertFalse(connectivityService.isInternetWalled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `other status than 204 means internet is walled`() {
|
||||
mockResponse(contentLength = 0, status = HttpStatus.SC_GONE)
|
||||
|
|
Loading…
Reference in a new issue