iphone - ASIHTTPRequest : Adding Header which should send with every request

标签 iphone objective-c ios ios4 asihttprequest

我正在一个使用 RESTful Web 服务的 iPhone 项目中工作。我需要在 iPhone 端发送的每个请求中发送一些跟踪代码或版本号。我正在考虑通过修改 ASIHTTPRequest 类在每个请求中添加一个 header 值。

  • ASIHTTPRequest 是否提供任何方法来执行此操作(无需修改框架文件)?
  • 如果我需要修改 ASIHTTPRequest 类,修改它的最佳位置是什么? (如 buildRequestHeaders.. )

  • 谢谢。

    最佳答案

    可能您可以编写一个新类,例如 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/

    相关文章:

    ios - 如何正确设置我的应用程序的最低 iOS 版本?

    iphone - NSDate dateFromString 已弃用?

    iphone - 设置游戏中心以允许通过蜂窝网络进行连接

    iphone - 如何使用 +fontWithName :size: and specify both the font family name and the specific style information for the font? 创建字体

    iphone - 将通配 rune 件名从主包复制到文档?

    ios - Swift - 如何更改当前用户位置标记的描述?

    ios - 在 ios 中没有调用 objc_getassociatedobject 的匹配函数

    objective-c - iOS - Facebook 连接注销不删除登录详细信息?

    objective-c - 仅当行被滑动时才从 UITableView 中删除删除按钮

    ios - 在完成另一种方法后执行方法中的问题-iOS