Browse Source

refactor(nextcloud): Allow any 2xx status code in WebDAV

pull/520/head
jld3103 1 year ago
parent
commit
4eadf43be2
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 15
      packages/nextcloud/lib/src/webdav/client.dart

15
packages/nextcloud/lib/src/webdav/client.dart

@ -20,8 +20,7 @@ class WebDavClient {
Future<HttpClientResponse> _send( Future<HttpClientResponse> _send(
final String method, final String method,
final String url, final String url, {
final List<int> expectedCodes, {
final Stream<Uint8List>? data, final Stream<Uint8List>? data,
final Map<String, String>? headers, final Map<String, String>? headers,
}) async { }) async {
@ -45,7 +44,7 @@ class WebDavClient {
final response = await request.close(); final response = await request.close();
if (!expectedCodes.contains(response.statusCode)) { if (response.statusCode > 299) {
throw DynamiteApiException( throw DynamiteApiException(
response.statusCode, response.statusCode,
response.responseHeaders, response.responseHeaders,
@ -102,7 +101,6 @@ class WebDavClient {
final response = await _send( final response = await _send(
'OPTIONS', 'OPTIONS',
_constructPath(), _constructPath(),
[200],
); );
final davCapabilities = response.headers['dav']?.cast<String>().first ?? ''; final davCapabilities = response.headers['dav']?.cast<String>().first ?? '';
final davSearchCapabilities = response.headers['dasl']?.cast<String>().first ?? ''; final davSearchCapabilities = response.headers['dasl']?.cast<String>().first ?? '';
@ -118,7 +116,6 @@ class WebDavClient {
Future<HttpClientResponse> mkcol(final String path) async => _send( Future<HttpClientResponse> mkcol(final String path) async => _send(
'MKCOL', 'MKCOL',
_constructPath(path), _constructPath(path),
[201],
); );
/// Deletes the resource at [path]. /// Deletes the resource at [path].
@ -127,7 +124,6 @@ class WebDavClient {
Future<HttpClientResponse> delete(final String path) => _send( Future<HttpClientResponse> delete(final String path) => _send(
'DELETE', 'DELETE',
_constructPath(path), _constructPath(path),
[204],
); );
/// Puts a new file at [path] with [localData] as content. /// Puts a new file at [path] with [localData] as content.
@ -165,7 +161,6 @@ class WebDavClient {
_send( _send(
'PUT', 'PUT',
_constructPath(path), _constructPath(path),
[200, 201, 204],
data: localData, data: localData,
headers: _getUploadHeaders( headers: _getUploadHeaders(
lastModified: lastModified, lastModified: lastModified,
@ -181,7 +176,6 @@ class WebDavClient {
Future<HttpClientResponse> getStream(final String path) async => _send( Future<HttpClientResponse> getStream(final String path) async => _send(
'GET', 'GET',
_constructPath(path), _constructPath(path),
[200],
); );
/// Retrieves the props for the resource at [path]. /// Retrieves the props for the resource at [path].
@ -199,7 +193,6 @@ class WebDavClient {
await _send( await _send(
'PROPFIND', 'PROPFIND',
_constructPath(path), _constructPath(path),
[207],
data: Stream.value( data: Stream.value(
Uint8List.fromList( Uint8List.fromList(
utf8.encode( utf8.encode(
@ -231,7 +224,6 @@ class WebDavClient {
await _send( await _send(
'REPORT', 'REPORT',
_constructPath(path), _constructPath(path),
[200, 207],
data: Stream.value( data: Stream.value(
Uint8List.fromList( Uint8List.fromList(
utf8.encode( utf8.encode(
@ -259,7 +251,6 @@ class WebDavClient {
final response = await _send( final response = await _send(
'PROPPATCH', 'PROPPATCH',
_constructPath(path), _constructPath(path),
[200, 207],
data: Stream.value( data: Stream.value(
Uint8List.fromList( Uint8List.fromList(
utf8.encode( utf8.encode(
@ -294,7 +285,6 @@ class WebDavClient {
_send( _send(
'MOVE', 'MOVE',
_constructPath(sourcePath), _constructPath(sourcePath),
[200, 201, 204],
headers: { headers: {
'Destination': _constructPath(destinationPath), 'Destination': _constructPath(destinationPath),
'Overwrite': overwrite ? 'T' : 'F', 'Overwrite': overwrite ? 'T' : 'F',
@ -313,7 +303,6 @@ class WebDavClient {
_send( _send(
'COPY', 'COPY',
_constructPath(sourcePath), _constructPath(sourcePath),
[200, 201, 204],
headers: { headers: {
'Destination': _constructPath(destinationPath), 'Destination': _constructPath(destinationPath),
'Overwrite': overwrite ? 'T' : 'F', 'Overwrite': overwrite ? 'T' : 'F',

Loading…
Cancel
Save