@@ -6,6 +6,7 @@ import 'package:dio/io.dart';
6
6
import 'package:http_mock_adapter/http_mock_adapter.dart' ;
7
7
import 'package:pop_network/src/i_api_manager.dart' ;
8
8
import 'package:pop_network/src/interceptors/pop_network_log_interceptor.dart' ;
9
+ import 'package:pop_network/src/mock/enums/mock_content_type_enum.dart' ;
9
10
import 'package:pop_network/src/mock/mock_reply_params.dart' ;
10
11
11
12
class ApiManager extends IApiManager {
@@ -213,12 +214,37 @@ class ApiManager extends IApiManager {
213
214
) async {
214
215
await request.reply (
215
216
params.status.code,
216
- json.decode (mock),
217
+ buildResponse (
218
+ contentType: params.contentType,
219
+ mock: mock,
220
+ ),
217
221
statusMessage: params.status.message,
218
222
delay: params.delay,
223
+ headers: {
224
+ Headers .contentTypeHeader: buildHeaders (
225
+ contentType: params.contentType,
226
+ ),
227
+ },
219
228
);
220
229
}
221
230
231
+ dynamic buildResponse ({
232
+ required MockContentTypeEnum contentType,
233
+ required String mock,
234
+ }) {
235
+ return switch (contentType) {
236
+ MockContentTypeEnum .json => json.decode (mock),
237
+ MockContentTypeEnum .plain => mock.substring (1 , mock.length - 1 ),
238
+ };
239
+ }
240
+
241
+ List <String > buildHeaders ({required MockContentTypeEnum contentType}) {
242
+ return switch (contentType) {
243
+ MockContentTypeEnum .json => ['application/json' ],
244
+ MockContentTypeEnum .plain => ['text/plain' ],
245
+ };
246
+ }
247
+
222
248
@override
223
249
Future <Response > download (
224
250
String path,
0 commit comments