【问题标题】:How to print NSMutableURLRequest?如何打印 NSMutableURLRequest?
【发布时间】:2023-03-12 04:20:01
【问题描述】:

如何使用 NSLog 打印 NSMutableURLRequest ?

【问题讨论】:

    标签: iphone objective-c nslog nsmutableurlrequest


    【解决方案1】:

    .allHTTPHeaderFields 返回带有标题内容的字典:

    NSLog(@"%@", [request allHTTPHeaderFields]);
    // {
    //    "Accept-Language" = "en;q=1";
    //    "Content-Length" = 190706;
    //    "Content-Type" = "multipart/form-data; boundary=Boundary+D90A259975186725";
    //    "User-Agent" = "...";
    // }
    

    或针对特定领域:

    NSString *field = @"Content-Type";
    NSLog(@"%@",[request valueForHTTPHeaderField:field]);
    // multipart/form-data; boundary=Boundary+D90A259975186725
    

    【讨论】:

      【解决方案2】:

      你试过了吗

      NSLog(@" %@", myMutableURLRequest);
      

      【讨论】:

      • request = 112.152.8.204/Service1.asmx> 这是日志中的 wat。但我需要查看添加到其中的值,包括标题设置:(
      • @chaitanya:如果你想确保得到标题,你需要编辑你的问题来这样说。就目前而言,这是正确的答案(因此我 +1)。
      • #chaitanya : 我的意思是你的 NSMutableURLRequest 值 :)
      猜你喜欢
      • 2012-11-02
      • 2015-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-12
      • 2014-07-14
      • 1970-01-01
      相关资源
      最近更新 更多