@@ -5,15 +5,14 @@ import 'dart:typed_data';
5
5
import 'package:dynamite_runtime/http_client.dart' ;
6
6
import 'package:http/http.dart' as http;
7
7
import 'package:meta/meta.dart' ;
8
+ import 'package:nextcloud/src/webdav/models.dart' ;
8
9
import 'package:nextcloud/src/webdav/path_uri.dart' ;
9
10
import 'package:nextcloud/src/webdav/props.dart' ;
11
+ import 'package:nextcloud/src/webdav/utils.dart' ;
10
12
import 'package:nextcloud/src/webdav/webdav.dart' ;
11
13
import 'package:nextcloud/utils.dart' ;
12
14
import 'package:universal_io/io.dart' hide HttpClient;
13
15
14
- /// Base path used on the server
15
- final webdavBase = PathUri .parse ('/remote.php/webdav' );
16
-
17
16
// ignore: do_not_use_environment
18
17
const bool _kIsWeb = bool .fromEnvironment ('dart.library.js_util' );
19
18
@@ -119,16 +118,6 @@ class WebDavClient {
119
118
120
119
Uri _constructUri ([PathUri ? path]) => constructUri (rootClient.baseURL, path);
121
120
122
- @visibleForTesting
123
- // ignore: public_member_api_docs
124
- static Uri constructUri (Uri baseURL, [PathUri ? path]) {
125
- final segments = baseURL.pathSegments.toList ()..addAll (webdavBase.pathSegments);
126
- if (path != null ) {
127
- segments.addAll (path.pathSegments);
128
- }
129
- return baseURL.replace (pathSegments: segments.where ((s) => s.isNotEmpty));
130
- }
131
-
132
121
Future <WebDavMultistatus > _parseResponse (http.StreamedResponse response) async =>
133
122
WebDavMultistatus .fromXmlElement (await response.stream.xml);
134
123
@@ -150,12 +139,7 @@ class WebDavClient {
150
139
_constructUri (),
151
140
);
152
141
153
- final davCapabilities = response.headers['dav' ];
154
- final davSearchCapabilities = response.headers['dasl' ];
155
- return WebDavOptions (
156
- davCapabilities? .split (',' ).map ((e) => e.trim ()).where ((e) => e.isNotEmpty).toSet (),
157
- davSearchCapabilities? .split (',' ).map ((e) => e.trim ()).where ((e) => e.isNotEmpty).toSet (),
158
- );
142
+ return parseWebDavOptions (response.headers);
159
143
}
160
144
161
145
/// Creates a collection at [path] .
@@ -428,42 +412,3 @@ class WebDavClient {
428
412
},
429
413
);
430
414
}
431
-
432
- /// WebDAV capabilities
433
- class WebDavOptions {
434
- /// Creates a new WebDavStatus.
435
- WebDavOptions (
436
- Set <String >? capabilities,
437
- Set <String >? searchCapabilities,
438
- ) : capabilities = capabilities ?? {},
439
- searchCapabilities = searchCapabilities ?? {};
440
-
441
- /// DAV capabilities as advertised by the server in the 'dav' header.
442
- Set <String > capabilities;
443
-
444
- /// DAV search and locating capabilities as advertised by the server in the 'dasl' header.
445
- Set <String > searchCapabilities;
446
- }
447
-
448
- /// Depth used for [WebDavClient.propfind] .
449
- ///
450
- /// See http://www.webdav.org/specs/rfc2518.html#HEADER_Depth for more information.
451
- enum WebDavDepth {
452
- /// Returns props of the resource.
453
- zero ('0' ),
454
-
455
- /// Returns props of the resource and its immediate children.
456
- ///
457
- /// Only works on collections and returns the same as [WebDavDepth.zero] for other resources.
458
- one ('1' ),
459
-
460
- /// Returns props of the resource and all its progeny.
461
- ///
462
- /// Only works on collections and returns the same as [WebDavDepth.zero] for other resources.
463
- infinity ('infinity' );
464
-
465
- const WebDavDepth (this .value);
466
-
467
- // ignore: public_member_api_docs
468
- final String value;
469
- }
0 commit comments