From 7750a8aa06908224bd3aa3e387999d765f6d9fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6ll?= Date: Tue, 25 Feb 2025 10:37:45 +0100 Subject: [PATCH] fix: allow 404 status code in OPTIONS request for WebDAV auth Some WebDAV servers return a 404 status for the OPTIONS request if the endpoint is not explicitly configured, even though authentication may still be valid. Previously, the implementation only allowed a 200 response and threw an error otherwise. This fix updates the authentication check to also accept 404, preventing unnecessary authentication failures and improving compatibility with a wider range of WebDAV servers. --- lib/src/webdav_dio.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/webdav_dio.dart b/lib/src/webdav_dio.dart index 157623c..a49dfc5 100644 --- a/lib/src/webdav_dio.dart +++ b/lib/src/webdav_dio.dart @@ -249,7 +249,7 @@ class WdDio with DioMixin implements Dio { }) async { // fix auth error var pResp = await this.wdOptions(self, path, cancelToken: cancelToken); - if (pResp.statusCode != 200) { + if ((pResp.statusCode != 200) && (pResp.statusCode != 404)) { throw newResponseError(pResp); } @@ -291,7 +291,7 @@ class WdDio with DioMixin implements Dio { }) async { // fix auth error var pResp = await this.wdOptions(self, path, cancelToken: cancelToken); - if (pResp.statusCode != 200) { + if ((pResp.statusCode != 200) && (pResp.statusCode != 404)) { throw newResponseError(pResp); } @@ -457,7 +457,7 @@ class WdDio with DioMixin implements Dio { }) async { // fix auth error var pResp = await this.wdOptions(self, path, cancelToken: cancelToken); - if (pResp.statusCode != 200) { + if ((pResp.statusCode != 200) && (pResp.statusCode != 404)) { throw newResponseError(pResp); } @@ -492,7 +492,7 @@ class WdDio with DioMixin implements Dio { }) async { // fix auth error var pResp = await this.wdOptions(self, path, cancelToken: cancelToken); - if (pResp.statusCode != 200) { + if ((pResp.statusCode != 200) && (pResp.statusCode != 404)) { throw newResponseError(pResp); }