Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用CFReadStreamCreateForHTTPRequest 截取网络请求,无果! #26

Open
jscpkare opened this issue Jan 7, 2020 · 0 comments
Open

Comments

@jscpkare
Copy link

jscpkare commented Jan 7, 2020

@implementation UIViewController (Hook1)
+ (void)load {
    struct rebinding _request_binding = { "CFReadStreamCreateForHTTPRequest", wt_CFReadStreamCreateForHTTPRequest, (void *)&original_CFReadStreamCreateForHTTPRequest};

    struct rebinding rebs[]={_request_binding};
    rebind_symbols(rebs, 1);
}

static CFReadStreamRef
wt_CFReadStreamCreateForHTTPRequest(CFAllocatorRef __nullable alloc, CFHTTPMessageRef request);
CFReadStreamRef wt_CFReadStreamCreateForHTTPRequest(CFAllocatorRef __nullable alloc, CFHTTPMessageRef request) {
    
    NSURL *url = (__bridge NSURL *)CFHTTPMessageCopyRequestURL(request);
    NSString *method = (__bridge NSString *)CFHTTPMessageCopyRequestMethod(request);
    
    CFReadStreamRef readStream = original_CFReadStreamCreateForHTTPRequest(alloc, request);
    
    return readStream;
}

static CFReadStreamRef (*original_CFReadStreamCreateForHTTPRequest)(CFAllocatorRef, CFHTTPMessageRef);
@end

我想监控 CFNetwork 返回的结果,但是我不能收到返回结果,我使用的是 AFNetworking 做网络请求,但是我没能得到结果,请帮我指点一下,到底是哪里不对,难道一定要使用自己封装的 CFNetwork 请求网络才可以拿到交换的信息吗,我感觉只要底层是使用的 cfnetwork 作为请求底层应该就可以拿到信息,请帮忙看看是不是我哪里使用的不当导致的,谢谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant