<tfoot id='aCjPi'></tfoot>
    • <bdo id='aCjPi'></bdo><ul id='aCjPi'></ul>
    <i id='aCjPi'><tr id='aCjPi'><dt id='aCjPi'><q id='aCjPi'><span id='aCjPi'><b id='aCjPi'><form id='aCjPi'><ins id='aCjPi'></ins><ul id='aCjPi'></ul><sub id='aCjPi'></sub></form><legend id='aCjPi'></legend><bdo id='aCjPi'><pre id='aCjPi'><center id='aCjPi'></center></pre></bdo></b><th id='aCjPi'></th></span></q></dt></tr></i><div id='aCjPi'><tfoot id='aCjPi'></tfoot><dl id='aCjPi'><fieldset id='aCjPi'></fieldset></dl></div>
    1. <legend id='aCjPi'><style id='aCjPi'><dir id='aCjPi'><q id='aCjPi'></q></dir></style></legend>

    2. <small id='aCjPi'></small><noframes id='aCjPi'>

      1. UIWebView 捕获响应标头

        UIWebView capturing the response headers(UIWebView 捕获响应标头)
          <tbody id='1dE59'></tbody>
        <legend id='1dE59'><style id='1dE59'><dir id='1dE59'><q id='1dE59'></q></dir></style></legend>
      2. <tfoot id='1dE59'></tfoot>
            • <bdo id='1dE59'></bdo><ul id='1dE59'></ul>

                <small id='1dE59'></small><noframes id='1dE59'>

                  <i id='1dE59'><tr id='1dE59'><dt id='1dE59'><q id='1dE59'><span id='1dE59'><b id='1dE59'><form id='1dE59'><ins id='1dE59'></ins><ul id='1dE59'></ul><sub id='1dE59'></sub></form><legend id='1dE59'></legend><bdo id='1dE59'><pre id='1dE59'><center id='1dE59'></center></pre></bdo></b><th id='1dE59'></th></span></q></dt></tr></i><div id='1dE59'><tfoot id='1dE59'></tfoot><dl id='1dE59'><fieldset id='1dE59'></fieldset></dl></div>
                  本文介绍了UIWebView 捕获响应标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我搜索/谷歌了很多,但无法得到关于如何在 UIWebview 中捕获 HTTP 响应标头的答案.假设我在应用程序启动时将用户重定向到 UIWebview 中的注册网关(已经处于活动状态),当用户完成注册时,应通知应用程序,并在注册时向用户分配成功的唯一 ID,该 ID 在 HTTP 响应标头中传回.

                  I searched/googled a lot but could not get the answer on how to capture HTTP response headers in UIWebview. Say I redirect to user to registration gateway(which is already active) in UIWebview on App Launch and when user finishes the registration, the app should be notified with the successful unique id assigned to the user on registration which is passed back in HTTP Response Headers.

                  是否有任何直接的方法可以使用 UIWebview 捕获/打印 HTTP 响应标头?

                  Is there any direct way to capture/print the HTTP Response headers using UIWebview?

                  推荐答案

                  我喜欢 Objective-c 运行时.有什么你想做但没有 API 的吗?DM;人力资源部.

                  I love the objective-c runtime. Is there something that you want to do but don't have an API for it? DM;HR.

                  好的,更严肃地说,这是解决此问题的方法.它将捕获从 CFNetwork 发起的每个 URL 响应,这正是 UIWebView 在幕后使用的.它还将捕获 AJAX 请求、图像加载等.

                  Alright, on a more serious note, here's the solution to this. It will capture every URL Response that initiated from CFNetwork, which is what UIWebView happens to use behind the scenes. It will also capture AJAX requests, image loads, and more.

                  为此添加过滤器可能就像对标头的内容执行正则表达式一样简单.

                  Adding a filter to this should probably be as easy as doing a regex on the contents of the headers.

                  @implementation NSURLResponse(webViewHack)
                  
                  static IMP originalImp;
                  
                  static char *rot13decode(const char *input)
                  {
                      static char output[100];
                  
                      char *result = output;
                  
                      // rot13 decode the string
                      while (*input) {
                          if (isalpha(*input))
                          {
                              int inputCase = isupper(*input) ? 'A' : 'a';
                  
                              *result = (((*input - inputCase) + 13) % 26) + inputCase;
                          }
                          else {
                              *result = *input;
                          }
                  
                          input++;
                          result++;
                      }
                  
                      *result = '';
                      return output;
                  }
                  
                  +(void) load {
                      SEL oldSel = sel_getUid(rot13decode("_vavgJvguPSHEYErfcbafr:"));
                  
                      Method old = class_getInstanceMethod(self, oldSel);
                      Method new = class_getInstanceMethod(self, @selector(__initWithCFURLResponse:));
                  
                      originalImp = method_getImplementation(old);
                      method_exchangeImplementations(old, new);
                  }
                  
                  -(id) __initWithCFURLResponse:(void *) cf {
                      if ((self = originalImp(self, _cmd, cf))) {
                          printf("-[%s %s]: %s", class_getName([self class]), sel_getName(_cmd), [[[self URL] description] UTF8String]);
                  
                          if ([self isKindOfClass:[NSHTTPURLResponse class]])
                          {
                              printf(" - %s", [[[(NSHTTPURLResponse *) self allHeaderFields] description] UTF8String]);
                          }
                  
                          printf("
                  ");
                      }
                  
                      return self;
                  }
                  
                  @end
                  

                  这篇关于UIWebView 捕获响应标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  UINavigationController inside a UITabBarController inside a UISplitViewController presented modally on iPhone(UISplitViewController 内的 UITabBarController 内的 UINavigationController 以模态方式呈现在 iPhone 上) - IT屋-程序员软件开发技术分
                  ViewController in UINavigationController orientation change(UINavigationController 中的 ViewController 方向更改)
                  Custom back button in UINavigationController(UINavigationController 中的自定义后退按钮)
                  How to add a navigation controller programmatically in code but not as initial view controller(如何在代码中以编程方式添加导航控制器,但不作为初始视图控制器)
                  How to get the previous viewcontroller that pushed my current view(如何获取推送我当前视图的上一个视图控制器)
                  The correct way to set a light status bar text color in iOS 7 based on different ViewControllers(iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法)
                    <bdo id='PmgUe'></bdo><ul id='PmgUe'></ul>
                    <legend id='PmgUe'><style id='PmgUe'><dir id='PmgUe'><q id='PmgUe'></q></dir></style></legend>

                    <tfoot id='PmgUe'></tfoot>

                        <tbody id='PmgUe'></tbody>
                      <i id='PmgUe'><tr id='PmgUe'><dt id='PmgUe'><q id='PmgUe'><span id='PmgUe'><b id='PmgUe'><form id='PmgUe'><ins id='PmgUe'></ins><ul id='PmgUe'></ul><sub id='PmgUe'></sub></form><legend id='PmgUe'></legend><bdo id='PmgUe'><pre id='PmgUe'><center id='PmgUe'></center></pre></bdo></b><th id='PmgUe'></th></span></q></dt></tr></i><div id='PmgUe'><tfoot id='PmgUe'></tfoot><dl id='PmgUe'><fieldset id='PmgUe'></fieldset></dl></div>

                      <small id='PmgUe'></small><noframes id='PmgUe'>