Commit cc7a71c 1 parent e37b775 commit cc7a71c Copy full SHA for cc7a71c
File tree 1 file changed +6
-2
lines changed
packages/nextcloud/lib/src/webdav
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
1
import 'package:dynamite_runtime/http_client.dart' ;
2
+ import 'package:dynamite_runtime/utils.dart' ;
2
3
import 'package:http/http.dart' as http;
3
4
4
5
/// A [http.Client] that sends the Nextcloud CSRF token.
@@ -20,14 +21,17 @@ final class WebDavCSRFClient with http.BaseClient {
20
21
@override
21
22
Future <http.StreamedResponse > send (http.BaseRequest request) async {
22
23
if (_token == null ) {
23
- final response = await _inner.get ( Uri .parse ('${_inner .baseURL }/index.php' ));
24
+ final response = await _inner.send (http. Request ( 'GET' , Uri .parse ('${_inner .baseURL }/index.php' ) ));
24
25
if (response.statusCode >= 300 ) {
25
26
throw DynamiteStatusCodeException (
26
27
response.statusCode,
27
28
);
28
29
}
29
30
30
- _token = RegExp ('data-requesttoken="([^"]*)"' ).firstMatch (response.body)! .group (1 );
31
+ final encoding = encodingForHeaders (response.headers);
32
+ final body = await response.stream.bytesToString (encoding);
33
+
34
+ _token = RegExp ('data-requesttoken="([^"]*)"' ).firstMatch (body)! .group (1 );
31
35
}
32
36
33
37
request.headers.addAll ({
You can’t perform that action at this time.
0 commit comments