iOS: add default content type

This commit is contained in:
pengfei.zhou 2021-08-11 11:33:17 +08:00 committed by osborn
parent 4579c4155d
commit ee737c5c17

View File

@ -25,7 +25,10 @@ @implementation DoricNetworkPlugin
- (void)request:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
NSString *url = [dic optString:@"url"];
NSString *method = [dic optString:@"method"];
NSDictionary <NSString *, NSString *> *headers = [dic optObject:@"headers"];
NSMutableDictionary <NSString *, NSString *> *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]];