美文网首页
iOS 处理application/text 请求

iOS 处理application/text 请求

作者: 小锤子_ | 来源:发表于2023-09-10 14:37 被阅读0次
 NSString *url = @"url"
 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];
//text 🈶️中文记得charset=utf-8
 [request setValue:@"application/text; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
 request.HTTPMethod = @"POST"

NSData *data =[@"text" dataUsingEncoding:NSUTF8StringEncoding];   
[request setHTTPBody:data];       
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable connectionError) {
                  
                
                       
                     
             }        
         }];
       [task resume];

相关文章

网友评论

      本文标题:iOS 处理application/text 请求

      本文链接:https://www.haomeiwen.com/subject/tvdsvdtx.html