Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:convert';
import 'package:built_value/serializer.dart';
import 'package:dynamite_runtime/http_client.dart';
import 'package:http/http.dart' as http;
import 'package:http_parser/http_parser.dart';
import 'package:logging/logging.dart';
import 'package:meta/meta.dart';

Expand Down Expand Up @@ -85,18 +84,18 @@ final class ResponseConverter<B, H> with Converter<http.Response, DynamiteRespon
final headers = _deserialize<H>(rawHeaders, serializer.serializers, serializer.headersType);

final contentType = rawHeaders['content-type'];
MediaType? mediaType;
http.MediaType? mediaType;
if (contentType != null) {
try {
mediaType = MediaType.parse(contentType);
mediaType = http.MediaType.parse(contentType);
} on FormatException catch (error, stackTrace) {
_logger.warning('Could not parse $contentType', error, stackTrace);
}
}

final body = switch (mediaType) {
MediaType(type: 'text') || MediaType(type: 'application', subtype: 'javascript') => input.body,
MediaType(type: 'application', subtype: 'json') => _deserialize<B>(
http.MediaType(type: 'text') || http.MediaType(type: 'application', subtype: 'javascript') => input.body,
http.MediaType(type: 'application', subtype: 'json') => _deserialize<B>(
json.decode(input.body),
serializer.serializers,
serializer.bodyType,
Expand Down
3 changes: 1 addition & 2 deletions packages/dynamite/packages/dynamite_runtime/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ dependencies:
built_collection: ^5.0.0
built_value: ^8.9.0
collection: ^1.0.0
http: ^1.2.0
http_parser: ^4.0.0
http: ^1.6.0
logging: ^1.0.0
meta: ^1.0.0

Expand Down
2 changes: 1 addition & 1 deletion packages/interceptor_http_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dev_dependencies:
git:
url: https://github.com/dart-lang/http
path: pkgs/http_client_conformance_tests
ref: 531d3e587c3214ad07bed1f52fac3f01112bc1ed
ref: 907782f5a792e7a5b0ed92f118c0ad91f3ecde51
mocktail: ^1.0.4
neon_lints:
path: ../neon_lints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
go_router_builder: ^3.0.0
http: ^1.5.0
http: ^1.6.0
mocktail: ^1.0.4
neon_lints:
path: ../../../neon_lints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:convert';

import 'package:http/http.dart';
import 'package:http_parser/http_parser.dart';
import 'package:interceptor_http_client/interceptor_http_client.dart';
import 'package:meta/meta.dart';
import 'package:nextcloud/nextcloud.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ dependencies:
built_collection: ^5.0.0
cookie_store:
path: ../../../cookie_store
http: ^1.0.0
http_parser: ^4.0.0
http: ^1.6.0
interceptor_http_client:
path: ../../../interceptor_http_client
logging: ^1.0.0
Expand All @@ -24,7 +23,7 @@ dev_dependencies:
git:
url: https://github.com/dart-lang/http
path: pkgs/http_client_conformance_tests
ref: 531d3e587c3214ad07bed1f52fac3f01112bc1ed
ref: 907782f5a792e7a5b0ed92f118c0ad91f3ecde51
mocktail: ^1.0.4
neon_lints:
path: ../../../neon_lints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:nextcloud/nextcloud.dart';
import 'package:test/test.dart';

final jsonHeaders = <String, String>{
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
};

final userNotLoggedInBody = JsonUtf8Encoder().convert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
go_router_builder: ^3.0.0
http: ^1.5.0
http: ^1.6.0
mocktail: ^1.0.4
neon_lints:
path: ../../../neon_lints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void main() {
),
200,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand Down Expand Up @@ -558,7 +558,7 @@ void main() {
),
201,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand All @@ -585,7 +585,7 @@ void main() {
'Accept': 'application/json',
'Authorization': 'Bearer user1',
'OCS-APIRequest': 'true',
'Content-Type': 'application/json; charset=utf-8',
'Content-Type': 'application/json',
'user-agent': 'neon',
},
),
Expand Down Expand Up @@ -648,7 +648,7 @@ void main() {
'Accept': 'application/json',
'Authorization': 'Bearer user1',
'OCS-APIRequest': 'true',
'Content-Type': 'application/json; charset=utf-8',
'Content-Type': 'application/json',
'user-agent': 'neon',
},
),
Expand Down Expand Up @@ -745,7 +745,7 @@ void main() {
),
201,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand Down Expand Up @@ -775,7 +775,7 @@ void main() {
'Accept': 'application/json',
'Authorization': 'Bearer user2',
'OCS-APIRequest': 'true',
'Content-Type': 'application/json; charset=utf-8',
'Content-Type': 'application/json',
'user-agent': 'neon',
},
),
Expand Down Expand Up @@ -841,7 +841,7 @@ void main() {
'Accept': 'application/json',
'Authorization': 'Bearer user2',
'OCS-APIRequest': 'true',
'Content-Type': 'application/json; charset=utf-8',
'Content-Type': 'application/json',
'user-agent': 'neon',
},
),
Expand Down Expand Up @@ -924,7 +924,7 @@ void main() {
),
200,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand Down Expand Up @@ -1036,7 +1036,7 @@ void main() {
),
200,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand Down Expand Up @@ -1070,7 +1070,7 @@ void main() {
),
201,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand Down Expand Up @@ -1123,7 +1123,7 @@ void main() {
'Accept': 'application/json',
'Authorization': 'Bearer user1',
'OCS-APIRequest': 'true',
'Content-Type': 'application/json; charset=utf-8',
'Content-Type': 'application/json',
'user-agent': 'neon',
},
),
Expand Down Expand Up @@ -1194,7 +1194,7 @@ void main() {
),
201,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand Down Expand Up @@ -1247,7 +1247,7 @@ void main() {
'Accept': 'application/json',
'Authorization': 'Bearer user1',
'OCS-APIRequest': 'true',
'Content-Type': 'application/json; charset=utf-8',
'Content-Type': 'application/json',
'user-agent': 'neon',
},
),
Expand Down Expand Up @@ -1305,7 +1305,7 @@ void main() {
),
200,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand Down Expand Up @@ -1366,7 +1366,7 @@ void main() {
'Accept': 'application/json',
'Authorization': 'Bearer user1',
'OCS-APIRequest': 'true',
'Content-Type': 'application/json; charset=utf-8',
'Content-Type': 'application/json',
'user-agent': 'neon',
},
),
Expand Down Expand Up @@ -1420,7 +1420,7 @@ void main() {
),
200,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand Down Expand Up @@ -1454,7 +1454,7 @@ void main() {
),
201,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand Down Expand Up @@ -1496,7 +1496,7 @@ void main() {
'Accept': 'application/json',
'Authorization': 'Bearer user1',
'OCS-APIRequest': 'true',
'Content-Type': 'application/json; charset=utf-8',
'Content-Type': 'application/json',
'user-agent': 'neon',
},
),
Expand Down Expand Up @@ -1567,7 +1567,7 @@ void main() {
),
201,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand Down Expand Up @@ -1608,7 +1608,7 @@ void main() {
'Accept': 'application/json',
'Authorization': 'Bearer user1',
'OCS-APIRequest': 'true',
'Content-Type': 'application/json; charset=utf-8',
'Content-Type': 'application/json',
'user-agent': 'neon',
},
),
Expand Down Expand Up @@ -1666,7 +1666,7 @@ void main() {
),
200,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
);
Expand Down Expand Up @@ -1715,7 +1715,7 @@ void main() {
'Accept': 'application/json',
'Authorization': 'Bearer user1',
'OCS-APIRequest': 'true',
'Content-Type': 'application/json; charset=utf-8',
'Content-Type': 'application/json',
'user-agent': 'neon',
},
),
Expand Down
2 changes: 1 addition & 1 deletion packages/neon_framework/packages/talk_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
go_router_builder: ^3.0.0
http: ^1.5.0
http: ^1.6.0
mocktail: ^1.0.4
neon_lints:
path: ../../../neon_lints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Account mockTalkAccount() {
}),
200,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
'x-chat-last-common-read': '0',
},
);
Expand Down Expand Up @@ -219,7 +219,7 @@ Account mockTalkAccount() {
}),
200,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
);
},
Expand Down Expand Up @@ -250,7 +250,7 @@ Account mockTalkAccount() {
}),
200,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
);
},
Expand Down Expand Up @@ -278,7 +278,7 @@ Account mockTalkAccount() {
}),
200,
headers: {
'content-type': 'application/json; charset=utf-8',
'content-type': 'application/json',
},
),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/neon_framework/test/request_manager_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void main() {
for (final entry in [
('server side', 500, <String, String>{}, kMaxTries),
('client side', 401, <String, String>{}, 1),
('webdav not found', 404, <String, String>{'content-type': 'application/xml; charset=utf-8'}, 1),
('webdav not found', 404, <String, String>{'content-type': 'application/xml'}, 1),
]) {
test(entry.$1, () async {
final subject = BehaviorSubject<Result<String>>();
Expand Down
2 changes: 1 addition & 1 deletion packages/nextcloud/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dev_dependencies:
git:
url: https://github.com/dart-lang/http
path: pkgs/http_client_conformance_tests
ref: 531d3e587c3214ad07bed1f52fac3f01112bc1ed
ref: 907782f5a792e7a5b0ed92f118c0ad91f3ecde51
mocktail: ^1.0.4
neon_lints:
path: ../neon_lints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
POST http://localhost/index\.php/apps/cookbook/api/v1/recipes
accept: application/json
authorization: Basic mock
content-type: application/json; charset=utf-8
content-type: application/json
\{"@type":"Recipe","description":"","url":"","image":"","recipeYield":1,"recipeCategory":"Test","tool":\[\],"recipeIngredient":\[\],"recipeInstructions":\[\],"nutrition":\{"@type":"NutritionInformation"\},"name":"My super cool recipe","keywords":"","dateCreated":"2023-01-01T00:00:00\.000Z","imageUrl":"","imagePlaceholderUrl":""\}
PUT http://localhost/index\.php/apps/cookbook/api/v1/category/Test
accept: application/json
authorization: Basic mock
content-type: application/json; charset=utf-8
content-type: application/json
\{"name":"Delicious Soup"\}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POST http://localhost/index\.php/apps/cookbook/api/v1/config
accept: application/json
authorization: Basic mock
content-type: application/json; charset=utf-8
content-type: application/json
\{"folder":"/"\}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POST http://localhost/index\.php/apps/cookbook/api/v1/import
accept: application/json
authorization: Basic mock
content-type: application/json; charset=utf-8
content-type: application/json
\{"url":"http://.*/static/recipe\.html"\}
Loading
Loading