本文介绍了ASIHTTPRequest addRequestHeader问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用ASIHttpRequest并使用GET方法将标头发送到服务器.我这样调用方法addRequestHeader
I am using ASIHttpRequest and make use GET method to send header to server. I call method addRequestHeader like this
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request addRequestHeader:@"myHeader" value:@"abc"];
它不起作用.但是,如果我使用NSMutableURLRequest向服务器添加标头和请求,它就可以工作.调用ASIHTTPRequest库的addRequestHeader方法时,我什么都不知道.有没有人看过这个问题?
It's not working. But if I use NSMutableURLRequest to add header and request to server, it works.I don't know anything wrong when calling addRequestHeader methods for ASIHTTPRequest library.Have anyone seen this issue?
推荐答案
您可以通过NSURLRequest
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.abc.com"]];
NSMutableURLRequest *mutableRequest = [request mutableCopy];
[mutableRequest addValue:@"AAA" forHTTPHeaderField:@"Hello-there"];
request = [mutableRequest copy];
NSLog(@"%@", request.allHTTPHeaderFields);
希望这会有所帮助..:)
Hope this helps .. :)
这篇关于ASIHTTPRequest addRequestHeader问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!