View Code? Open in Web Editor
NEW
SJNetwork is a high level network request tool based on AFNetworking and inspired on YTKNetwork.
License: MIT License
Ruby 0.08%
Objective-C 98.89%
Shell 1.03%
sjnetwork's People
Contributors
sjnetwork's Issues
不知道是用了哪些高版本的东西,为什么没有兼容到iOS8,现在8的比重还是有一些的。
目前想实现控制文件最大下载数,分析源码后目前有两个思路:
1.SJNetworkRequestEngine.m 第53行,通过这里设置
_sessionManager.operationQueue.maxConcurrentOperationCount = 5;
AFNetworking可以自行控制吗?还是会取消超过5个之外的请求?
2.SJNetworkRequestPool.h 第99行
-(NSInteger)currentRequestCount;
通过自己控制这个数量来实现
请问有更好的思路吗?
=========== NSError object:Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set., NSUnderlyingError=0x281e1d4d0 {Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: service unavailable (503)" UserInfo={NSLocalizedDescription=Request failed: service unavailable (503), NSErrorFailingURLKey=https://www.baidu.com, com.alamofire.serialization.response.error.data=<3c68746d 6c3e3c62 6f64793e 3c68313e 35303320 53657276 69636520 556e6176 61696c61 626c653c 2f68313e 0a4e6f20 73657276 65722069 73206176 61696c61 626c6520 746f2068 616e646c 65207468 69732072 65717565 73742e0a 3c2f626f 64793e3c 2f68746d 6c3e0a0a>, com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x28106e8a0> { URL: https://www.baidu.com } { Status Code: 503, Headers {
"Cache-Control" = (
"no-cache"
);
Connection = (
close
);
"Content-Type" = (
"text/html"
);
} }}}}
=========== Status code:3840
有没有什么方法直接获取原始json字符串,没有转为responseObject之前的字符串。有些时候需要打印一下该字符串,比如responseObject为nil,但是返回成功,和后台联调接口的时候经常用到
后台请求的content-type只支持 text/html。但是你的RequestSerializer 设置成了 _sessionManager.requestSerializer = [AFJSONRequestSerializer serializer]
好像只能改源代码。。
另外还有个小建议就是 defailtParameters 和 addCustomHeader 能否用block的方式实时添加。比如用户请求 token 成功,之后的请求就都需要在请求头中添加 Authoraization=Bearer token
这种需求。现在好像只能在每个请求前手动添加(如果初始化时还未请求tokenaddCustomHeader
未设置token的话)。