File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ @implementation STHTTPNetTaskQueueHandler
1414 NSURL *_baseURL;
1515 NSURLSession *_urlSession;
1616 NSDictionary *_methodMap;
17+ NSDictionary *_contentTypeMap;
1718 NSString *_formDataBoundary;
1819}
1920
@@ -28,6 +29,8 @@ - (instancetype)initWithBaseURL:(NSURL *)baseURL
2829 @(STHTTPNetTaskPatch): @" PATCH" ,
2930 @(STHTTPNetTaskPost): @" POST" ,
3031 @(STHTTPNetTaskPut): @" PUT" };
32+ _contentTypeMap = @{ @(STHTTPNetTaskRequestJSON): @" application/json; charset=utf-8" ,
33+ @(STHTTPNetTaskRequestKeyValueString): @" application/x-www-form-urlencoded" };
3134 _formDataBoundary = [NSString stringWithFormat: @" ST-Boundary-%@ " , [[NSUUID UUID ] UUIDString ]];
3235 }
3336 return self;
@@ -118,6 +121,7 @@ - (void)netTaskQueue:(STNetTaskQueue *)netTaskQueue task:(STNetTask *)task taskI
118121 NSDictionary *datas = httpTask.datas ;
119122 if (!datas.count ) {
120123 request.HTTPBody = [self bodyDataFromParameters: parameters requestType: httpTask.requestType];
124+ [request setValue: _contentTypeMap[@(httpTask.requestType)] forHTTPHeaderField: @" Content-Type" ];
121125 sessionTask = [_urlSession dataTaskWithRequest: request completionHandler: completionHandler];
122126 }
123127 else {
You can’t perform that action at this time.
0 commit comments