我正在一个使用 RESTful Web 服务的 iPhone 项目中工作。我需要在 iPhone 端发送的每个请求中发送一些跟踪代码或版本号。我正在考虑通过修改 ASIHTTPRequest 类在每个请求中添加一个 header 值。
谢谢。
最佳答案
可能您可以编写一个新类,例如 MyASIHttprequest 并覆盖方法 requestwithURL
+ (MyASIHTTPrequest *) requestWithURL:url{
MyASIHTTPrequest *request;
if (request = [super requestWithUrl:url]){
[request addRequestHeader:@"" value:@""];
}
return request;
}
或者您可以编写一个方法来添加 header ,但也许每次您新建一个 asihttprequest 时,都应该调用此方法来添加 header ;
关于iphone - ASIHTTPRequest : Adding Header which should send with every request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9408581/