From ee737c5c17eef2e4dc289211c88df2416bf7d9dd Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 11 Aug 2021 11:33:17 +0800 Subject: [PATCH] iOS: add default content type --- doric-iOS/Pod/Classes/Plugin/DoricNetworkPlugin.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doric-iOS/Pod/Classes/Plugin/DoricNetworkPlugin.m b/doric-iOS/Pod/Classes/Plugin/DoricNetworkPlugin.m index 9499f0b1..61dcc26f 100644 --- a/doric-iOS/Pod/Classes/Plugin/DoricNetworkPlugin.m +++ b/doric-iOS/Pod/Classes/Plugin/DoricNetworkPlugin.m @@ -25,7 +25,10 @@ @implementation DoricNetworkPlugin - (void)request:(NSDictionary *)dic withPromise:(DoricPromise *)promise { NSString *url = [dic optString:@"url"]; NSString *method = [dic optString:@"method"]; - NSDictionary *headers = [dic optObject:@"headers"]; + NSMutableDictionary *headers = [[dic optObject:@"headers"] mutableCopy]; + if(!headers[@"Content-Type"]){ + headers[@"Content-Type"] = @"application/json; charset=utf-8"; + } NSNumber *timeout = [dic optNumber:@"timeout"]; NSString *data = [dic optString:@"data"]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];