<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 捕获响应标头

        时间:2023-06-11
          <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 捕获响应标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Android : 使用非 root 的 android 设备捕获 HTTP 请求 下一篇:应该使用什么标头将 GZIP 压缩 JSON 从 Android 客户端发送到服务器?

                  相关文章

                    <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>

                  <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'>