Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
84b08f1b
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
12 个月 前同步成功
通知
166
Star
19623
Fork
3062
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DoraemonKit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
84b08f1b
编写于
2月 20, 2021
作者:
[
[linjizong]
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
550b03cb
e5fbb96b
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
170 addition
and
120 deletion
+170
-120
Doc/iOS-ReleaseNotes.md
Doc/iOS-ReleaseNotes.md
+5
-2
DoraemonKit.podspec
DoraemonKit.podspec
+1
-1
README.md
README.md
+4
-3
iOS/DoraemonKit/Src/Core/Network/Interceptor/DoraemonNSURLProtocol.m
...nKit/Src/Core/Network/Interceptor/DoraemonNSURLProtocol.m
+4
-2
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/DoraemonNetFlowHttpModel.h
...n/Performance/NetFlow/Function/DoraemonNetFlowHttpModel.h
+1
-1
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/DoraemonNetFlowHttpModel.m
...n/Performance/NetFlow/Function/DoraemonNetFlowHttpModel.m
+8
-13
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/DoraemonNetFlowManager.h
...gin/Performance/NetFlow/Function/DoraemonNetFlowManager.h
+4
-0
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/DoraemonNetFlowManager.m
...gin/Performance/NetFlow/Function/DoraemonNetFlowManager.m
+74
-13
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/Util/DoraemonUrlUtil.h
...lugin/Performance/NetFlow/Function/Util/DoraemonUrlUtil.h
+3
-3
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/Util/DoraemonUrlUtil.m
...lugin/Performance/NetFlow/Function/Util/DoraemonUrlUtil.m
+11
-30
iOS/DoraemonKit/Src/Core/Plugin/Performance/WeakNetwork/Function/DoraemonWeakNetworkManager.m
...ormance/WeakNetwork/Function/DoraemonWeakNetworkManager.m
+3
-1
iOS/DoraemonKit/Src/Core/Plugin/Platform/Mock/Function/DoraemonMockManager.m
.../Core/Plugin/Platform/Mock/Function/DoraemonMockManager.m
+2
-1
iOS/DoraemonKitDemo/DoraemonKitDemo/DemoVC/Net/ NSURLProtocol/DoraemonDemoURLProtocol1.m
...Demo/DemoVC/Net/ NSURLProtocol/DoraemonDemoURLProtocol1.m
+6
-4
iOS/DoraemonKitDemo/DoraemonKitDemo/DemoVC/Net/ NSURLProtocol/DoraemonDemoURLProtocol2.m
...Demo/DemoVC/Net/ NSURLProtocol/DoraemonDemoURLProtocol2.m
+6
-4
iOS/DoraemonKitDemo/DoraemonKitDemo/DemoVC/Net/DoraemonDemoNetViewController.m
...oraemonKitDemo/DemoVC/Net/DoraemonDemoNetViewController.m
+6
-5
iOS/DoraemonKitDemo/DoraemonKitDemo/DemoVC/Performance/DoraemonDemoPerformanceViewController.m
...emoVC/Performance/DoraemonDemoPerformanceViewController.m
+4
-3
iOS/DoraemonKitDemo/Podfile
iOS/DoraemonKitDemo/Podfile
+1
-1
iOS/DoraemonKitDemo/Podfile.lock
iOS/DoraemonKitDemo/Podfile.lock
+27
-33
未找到文件。
Doc/iOS-ReleaseNotes.md
浏览文件 @
84b08f1b
# Release Notes
### 3.0.7
1、DoKit iOS github issues bug fixed
### 3.0.4
1、DoKit iOS端文件同步助手正式上线
### 3.0.2
1、支持每一个内置Kit,进行位置重排,添加删除某一个Kit
...
...
@@ -242,4 +245,4 @@
3、性能工具:帧率、CPU、内存、流量、自定义
4、视觉工具:颜色吸管、组件检查、对齐标尺
\ No newline at end of file
4、视觉工具:颜色吸管、组件检查、对齐标尺
DoraemonKit.podspec
浏览文件 @
84b08f1b
...
...
@@ -7,7 +7,7 @@
Pod
::
Spec
.
new
do
|
s
|
s
.
name
=
'DoraemonKit'
s
.
version
=
'3.0.
6
'
s
.
version
=
'3.0.
7
'
s
.
summary
=
'iOS各式各样的工具集合'
s
.
description
=
<<-
DESC
iOS各式各样的工具集合 Desc
...
...
README.md
浏览文件 @
84b08f1b
...
...
@@ -27,7 +27,7 @@
<img
src=
"https://javer.oss-cn-shanghai.aliyuncs.com/doraemon/github/DoraemonKit_github.png"
width =
"150"
height =
"150"
alt=
"DoraemonKit"
align=
left
/>
<img
src=
"https://img.shields.io/github/license/didi/DoraemonKit.svg"
align=
left
/>
<img
src=
"https://img.shields.io/badge/Android-3.3.5-blue.svg"
align=
left
/>
<img
src=
"https://img.shields.io/badge/iOS-3.0.
4
-yellow.svg"
align=
left
/>
<img
src=
"https://img.shields.io/badge/iOS-3.0.
7
-yellow.svg"
align=
left
/>
<img
src=
"https://img.shields.io/badge/Flutter-0.2.12-blue.svg"
align=
left
/>
<img
src=
"https://img.shields.io/badge/miniapp-0.0.1-red.svg"
align=
left
/>
<img
src=
"https://img.shields.io/badge/PRs-welcome-brightgreen.svg"
align=
left
/>
...
...
@@ -238,7 +238,7 @@ tips : 如果使用我们滴滴优秀的开源跨端方案 [chameleon](https:/
[
yixiangboy
](
https://github.com/yixiangboy
)
、
[
jtsky
](
https://github.com/jtsky
)
、
[
LinJZong
](
https://github.com/LinJZong
)
、
[
ydlsl
](
https://github.com/ydlsl
)
、
[
changzuozhen
](
https://github.com/changzuozhen
)
、
[
jayconscious
](
https://github.com/jayconscious
)
**贡献者榜单**
...
...
@@ -270,7 +270,8 @@ tips : 如果使用我们滴滴优秀的开源跨端方案 [chameleon](https:/
[
sagdragon
](
https://github.com/sagdragon
)
、
[
ccworld1000
](
https://github.com/ccworld1000
)
、
[
HDB-Li
](
https://github.com/HDB-Li
)
、
[
yu-jianfeng
](
https://github.com/yu-jianfeng
)
[
yu-jianfeng
](
https://github.com/yu-jianfeng
)
、
[
ydlsl
](
https://github.com/ydlsl
)
如何成为外部贡献者? 提交有意义的PR,并被采纳。
...
...
iOS/DoraemonKit/Src/Core/Network/Interceptor/DoraemonNSURLProtocol.m
浏览文件 @
84b08f1b
...
...
@@ -98,8 +98,10 @@ static NSString * const kDoraemonProtocolKey = @"doraemon_protocol_key";
});
}
else
if
(
DoraemonWeakNetwork_WeakSpeed
==
[[
DoraemonNetworkInterceptor
shareInstance
].
weakDelegate
weakNetSelecte
]){
DoKitLog
(
@"yd WeakUpFlow Net"
);
[[
DoraemonNetworkInterceptor
shareInstance
].
weakDelegate
handleWeak
:[
DoraemonUrlUtil
getHttpBodyFromRequest
:
self
.
request
]
isDown
:
NO
];
[
self
.
task
resume
];
[[
DoraemonNetFlowManager
shareInstance
]
httpBodyFromRequest
:
self
.
request
bodyCallBack
:
^
(
NSData
*
body
)
{
[[
DoraemonNetworkInterceptor
shareInstance
].
weakDelegate
handleWeak
:
body
isDown
:
NO
];
[
self
.
task
resume
];
}];
}
else
{
[
self
.
task
resume
];
}
...
...
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/DoraemonNetFlowHttpModel.h
浏览文件 @
84b08f1b
...
...
@@ -28,6 +28,6 @@
@property
(
nonatomic
,
copy
)
NSString
*
topVc
;
//流量触发时候的顶层vc
+
(
DoraemonNetFlowHttpModel
*
)
dealWithResponseData
:(
NSData
*
)
responseData
response
:(
NSURLResponse
*
)
response
request
:(
NSURLRequest
*
)
request
;
+
(
void
)
dealWithResponseData
:(
NSData
*
)
responseData
response
:(
NSURLResponse
*
)
response
request
:(
NSURLRequest
*
)
request
complete
:(
void
(
^
)(
DoraemonNetFlowHttpModel
*
model
))
complete
;
@end
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/DoraemonNetFlowHttpModel.m
浏览文件 @
84b08f1b
...
...
@@ -6,24 +6,19 @@
//
#import "DoraemonNetFlowHttpModel.h"
#import "DoraemonNetFlowManager.h"
#import "NSURLRequest+Doraemon.h"
#import "DoraemonUrlUtil.h"
@implementation
DoraemonNetFlowHttpModel
+
(
DoraemonNetFlowHttpModel
*
)
dealWithResponseData
:(
NSData
*
)
responseData
response
:(
NSURLResponse
*
)
response
request
:(
NSURLRequest
*
)
request
{
+
(
void
)
dealWithResponseData
:(
NSData
*
)
responseData
response
:(
NSURLResponse
*
)
response
request
:(
NSURLRequest
*
)
request
complete
:(
void
(
^
)(
DoraemonNetFlowHttpModel
*
model
))
complete
{
DoraemonNetFlowHttpModel
*
httpModel
=
[[
DoraemonNetFlowHttpModel
alloc
]
init
];
//request
httpModel
.
request
=
request
;
httpModel
.
requestId
=
request
.
requestId
;
httpModel
.
url
=
[
request
.
URL
absoluteString
];
httpModel
.
method
=
request
.
HTTPMethod
;
NSData
*
httpBody
=
[
DoraemonUrlUtil
getHttpBodyFromRequest
:
request
];
httpModel
.
requestBody
=
[
DoraemonUrlUtil
convertJsonFromData
:
httpBody
];
httpModel
.
uploadFlow
=
[
NSString
stringWithFormat
:
@"%zi"
,[
DoraemonUrlUtil
getRequestLength
:
request
]];
//response
httpModel
.
mineType
=
response
.
MIMEType
;
httpModel
.
response
=
response
;
...
...
@@ -33,12 +28,12 @@
httpModel
.
responseBody
=
[
DoraemonUrlUtil
convertJsonFromData
:
responseData
];
httpModel
.
totalDuration
=
[
NSString
stringWithFormat
:
@"%fs"
,[[
NSDate
date
]
timeIntervalSince1970
]
-
request
.
startTime
.
doubleValue
];
httpModel
.
downFlow
=
[
NSString
stringWithFormat
:
@"%lli"
,[
DoraemonUrlUtil
getResponseLength
:(
NSHTTPURLResponse
*
)
response
data
:
responseData
]];
return
httpModel
;
[[
DoraemonNetFlowManager
shareInstance
]
httpBodyFromRequest
:
request
bodyCallBack
:
^
(
NSData
*
body
)
{
httpModel
.
requestBody
=
[
DoraemonUrlUtil
convertJsonFromData
:
body
];
NSUInteger
length
=
[
DoraemonUrlUtil
getHeadersLengthWithRequest
:
request
]
+
[
body
length
];
httpModel
.
uploadFlow
=
[
NSString
stringWithFormat
:
@"%zi"
,
length
];
complete
(
httpModel
);
}];
}
@end
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/DoraemonNetFlowManager.h
浏览文件 @
84b08f1b
...
...
@@ -7,6 +7,8 @@
#import <Foundation/Foundation.h>
typedef
void
(
^
HttpBodyCallBack
)(
NSData
*
body
);
@interface
DoraemonNetFlowManager
:
NSObject
+
(
DoraemonNetFlowManager
*
)
shareInstance
;
...
...
@@ -16,4 +18,6 @@
-
(
void
)
canInterceptNetFlow
:(
BOOL
)
enable
;
-
(
void
)
httpBodyFromRequest
:(
NSURLRequest
*
)
request
bodyCallBack
:(
HttpBodyCallBack
)
complete
;
@end
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/DoraemonNetFlowManager.m
浏览文件 @
84b08f1b
...
...
@@ -13,7 +13,10 @@
#import "UIViewController+Doraemon.h"
#import "DoraemonHealthManager.h"
@interface
DoraemonNetFlowManager
()
<
DoraemonNetworkInterceptorDelegate
>
@interface
DoraemonNetFlowManager
()
<
DoraemonNetworkInterceptorDelegate
,
NSStreamDelegate
>
@property
(
nonatomic
,
copy
)
HttpBodyCallBack
bodyCallBack
;
@property
(
nonatomic
,
strong
)
NSMutableData
*
bodyData
;
@end
...
...
@@ -40,21 +43,79 @@
}
}
-
(
void
)
httpBodyFromRequest
:(
NSURLRequest
*
)
request
bodyCallBack
:(
HttpBodyCallBack
)
complete
{
NSData
*
httpBody
=
nil
;
if
(
request
.
HTTPBody
)
{
httpBody
=
request
.
HTTPBody
;
complete
(
httpBody
);
return
;
}
if
([
request
.
HTTPMethod
isEqualToString
:
@"POST"
])
{
NSInputStream
*
stream
=
request
.
HTTPBodyStream
;
[
stream
setDelegate
:
self
];
self
.
bodyCallBack
=
complete
;
[
stream
scheduleInRunLoop
:[
NSRunLoop
currentRunLoop
]
forMode
:
NSDefaultRunLoopMode
];
[
stream
open
];
}
else
{
complete
(
httpBody
);
}
}
#pragma mark -- NSStreamDelegate
-
(
void
)
stream
:(
NSStream
*
)
aStream
handleEvent
:(
NSStreamEvent
)
eventCode
{
switch
(
eventCode
)
{
case
NSStreamEventHasBytesAvailable
:
{
if
(
!
self
.
bodyData
)
{
self
.
bodyData
=
[
NSMutableData
data
];
}
uint8_t
buf
[
1024
];
NSInteger
len
=
0
;
len
=
[(
NSInputStream
*
)
aStream
read
:
buf
maxLength
:
1024
];
if
(
len
)
{
[
self
.
bodyData
appendBytes
:(
const
void
*
)
buf
length
:
len
];
}
}
break
;
case
NSStreamEventErrorOccurred
:
{
NSError
*
error
=
[
aStream
streamError
];
NSString
*
errorInfo
=
[
NSString
stringWithFormat
:
@"Failed while reading stream; error '%@' (code %ld)"
,
error
.
localizedDescription
,
error
.
code
];
NSLog
(
@"%@"
,
errorInfo
);
}
break
;
case
NSStreamEventEndEncountered
:
{
[
aStream
close
];
[
aStream
removeFromRunLoop
:[
NSRunLoop
currentRunLoop
]
forMode
:
NSDefaultRunLoopMode
];
aStream
=
nil
;
if
(
self
.
bodyCallBack
)
{
self
.
bodyCallBack
([
self
.
bodyData
copy
]);
}
self
.
bodyData
=
nil
;
}
break
;
default:
break
;
}
}
#pragma mark -- DoraemonNetworkInterceptorDelegate
-
(
void
)
doraemonNetworkInterceptorDidReceiveData
:(
NSData
*
)
data
response
:(
NSURLResponse
*
)
response
request
:(
NSURLRequest
*
)
request
error
:(
NSError
*
)
error
startTime
:(
NSTimeInterval
)
startTime
{
DoraemonNetFlowHttpModel
*
httpModel
=
[
DoraemonNetFlowHttpModel
dealWithResponseData
:
data
response
:
response
request
:
request
];
if
(
!
response
)
{
httpModel
.
statusCode
=
error
.
localizedDescription
;
}
httpModel
.
startTime
=
startTime
;
httpModel
.
endTime
=
[[
NSDate
date
]
timeIntervalSince1970
];
httpModel
.
totalDuration
=
[
NSString
stringWithFormat
:
@"%f"
,[[
NSDate
date
]
timeIntervalSince1970
]
-
startTime
];
httpModel
.
topVc
=
NSStringFromClass
([[
UIViewController
topViewControllerForKeyWindow
]
class
]);
[[
DoraemonNetFlowDataSource
shareInstance
]
addHttpModel
:
httpModel
];
[[
DoraemonHealthManager
sharedInstance
]
addHttpModel
:
httpModel
];
[
DoraemonNetFlowHttpModel
dealWithResponseData
:
data
response
:
response
request
:
request
complete
:^
(
DoraemonNetFlowHttpModel
*
httpModel
)
{
if
(
!
response
)
{
httpModel
.
statusCode
=
error
.
localizedDescription
;
}
httpModel
.
startTime
=
startTime
;
httpModel
.
endTime
=
[[
NSDate
date
]
timeIntervalSince1970
];
httpModel
.
totalDuration
=
[
NSString
stringWithFormat
:
@"%f"
,[[
NSDate
date
]
timeIntervalSince1970
]
-
startTime
];
httpModel
.
topVc
=
NSStringFromClass
([[
UIViewController
topViewControllerForKeyWindow
]
class
]);
[[
DoraemonNetFlowDataSource
shareInstance
]
addHttpModel
:
httpModel
];
[[
DoraemonHealthManager
sharedInstance
]
addHttpModel
:
httpModel
];
}];
}
-
(
BOOL
)
shouldIntercept
{
...
...
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/Util/DoraemonUrlUtil.h
浏览文件 @
84b08f1b
...
...
@@ -13,7 +13,9 @@
+
(
NSDictionary
*
)
convertDicFromData
:(
NSData
*
)
data
;
+
(
NSUInteger
)
getRequestLength
:(
NSURLRequest
*
)
request
;
+
(
NSUInteger
)
getHeadersLengthWithRequest
:(
NSURLRequest
*
)
request
;
+
(
void
)
requestLength
:(
NSURLRequest
*
)
request
callBack
:(
void
(
^
)(
NSUInteger
))
callBack
;
+
(
NSUInteger
)
getHeadersLength
:(
NSDictionary
*
)
headers
;
...
...
@@ -21,6 +23,4 @@
+
(
int64_t
)
getResponseLength
:(
NSHTTPURLResponse
*
)
response
data
:(
NSData
*
)
responseData
;
+
(
NSData
*
)
getHttpBodyFromRequest
:(
NSURLRequest
*
)
request
;
@end
iOS/DoraemonKit/Src/Core/Plugin/Performance/NetFlow/Function/Util/DoraemonUrlUtil.m
浏览文件 @
84b08f1b
...
...
@@ -6,6 +6,7 @@
//
#import "DoraemonUrlUtil.h"
#import "DoraemonNetFlowManager.h"
@implementation
DoraemonUrlUtil
...
...
@@ -39,7 +40,15 @@
return
jsonObj
;
}
+
(
NSUInteger
)
getRequestLength
:(
NSURLRequest
*
)
request
{
+
(
void
)
requestLength
:(
NSURLRequest
*
)
request
callBack
:(
void
(
^
)(
NSUInteger
))
callBack
{
NSUInteger
headersLength
=
[
self
getHeadersLengthWithRequest
:
request
];
[[
DoraemonNetFlowManager
shareInstance
]
httpBodyFromRequest
:
request
bodyCallBack
:
^
(
NSData
*
body
)
{
NSUInteger
bodyLength
=
[
body
length
];
callBack
(
headersLength
+
bodyLength
);
}];
}
+
(
NSUInteger
)
getHeadersLengthWithRequest
:(
NSURLRequest
*
)
request
{
NSDictionary
<
NSString
*
,
NSString
*>
*
headerFields
=
request
.
allHTTPHeaderFields
;
NSDictionary
<
NSString
*
,
NSString
*>
*
cookiesHeader
=
[
self
getCookies
:
request
];
if
(
cookiesHeader
.
count
)
{
...
...
@@ -47,11 +56,7 @@
[
headerFieldsWithCookies
addEntriesFromDictionary
:
cookiesHeader
];
headerFields
=
[
headerFieldsWithCookies
copy
];
}
NSUInteger
headersLength
=
[
self
getHeadersLength
:
headerFields
];
NSData
*
httpBody
=
[[
self
class
]
getHttpBodyFromRequest
:
request
];
NSUInteger
bodyLength
=
[
httpBody
length
];
return
headersLength
+
bodyLength
;
return
[
self
getHeadersLength
:
headerFields
];
}
+
(
NSUInteger
)
getHeadersLength
:(
NSDictionary
*
)
headers
{
...
...
@@ -95,28 +100,4 @@
return
responseLength
;
}
+
(
NSData
*
)
getHttpBodyFromRequest
:(
NSURLRequest
*
)
request
{
NSData
*
httpBody
;
if
(
request
.
HTTPBody
)
{
httpBody
=
request
.
HTTPBody
;
}
else
{
if
([
request
.
HTTPMethod
isEqualToString
:
@"POST"
])
{
if
(
!
request
.
HTTPBody
)
{
uint8_t
d
[
1024
]
=
{
0
};
NSInputStream
*
stream
=
request
.
HTTPBodyStream
;
NSMutableData
*
data
=
[[
NSMutableData
alloc
]
init
];
[
stream
open
];
while
([
stream
hasBytesAvailable
])
{
NSInteger
len
=
[
stream
read
:
d
maxLength
:
1024
];
if
(
len
>
0
&&
stream
.
streamError
==
nil
)
{
[
data
appendBytes
:(
void
*
)
d
length
:
len
];
}
}
httpBody
=
[
data
copy
];
[
stream
close
];
}
}
}
return
httpBody
;
}
@end
iOS/DoraemonKit/Src/Core/Plugin/Performance/WeakNetwork/Function/DoraemonWeakNetworkManager.m
浏览文件 @
84b08f1b
...
...
@@ -115,7 +115,9 @@
#pragma mark -- DoraemonNetworkInterceptorDelegate
-
(
void
)
doraemonNetworkInterceptorDidReceiveData
:(
NSData
*
)
data
response
:(
NSURLResponse
*
)
response
request
:(
NSURLRequest
*
)
request
error
:(
NSError
*
)
error
startTime
:(
NSTimeInterval
)
startTime
{
[[
DoraemonWeakNetworkWindow
shareInstance
]
updateFlowValue
:[
NSString
stringWithFormat
:
@"%zi"
,[
DoraemonUrlUtil
getRequestLength
:
request
]]
downFlow
:[
NSString
stringWithFormat
:
@"%lli"
,[
DoraemonUrlUtil
getResponseLength
:(
NSHTTPURLResponse
*
)
response
data
:
data
]]
fromWeak
:
NO
];
[
DoraemonUrlUtil
requestLength
:
request
callBack
:
^
(
NSUInteger
length
)
{
[[
DoraemonWeakNetworkWindow
shareInstance
]
updateFlowValue
:[
NSString
stringWithFormat
:
@"%zi"
,
length
]
downFlow
:[
NSString
stringWithFormat
:
@"%lli"
,[
DoraemonUrlUtil
getResponseLength
:(
NSHTTPURLResponse
*
)
response
data
:
data
]]
fromWeak
:
NO
];
}];
}
-
(
BOOL
)
shouldIntercept
{
...
...
iOS/DoraemonKit/Src/Core/Plugin/Platform/Mock/Function/DoraemonMockManager.m
浏览文件 @
84b08f1b
...
...
@@ -181,7 +181,8 @@
-
(
DoraemonMockBaseModel
*
)
getSelectedData
:(
NSURLRequest
*
)
request
dataArray
:(
NSArray
*
)
dataArray
{
NSString
*
path
=
request
.
URL
.
path
;
NSString
*
query
=
request
.
URL
.
query
;
NSData
*
httpBody
=
[
DoraemonUrlUtil
getHttpBodyFromRequest
:
request
];
// 这里暂时使用不严谨body match
NSData
*
httpBody
=
request
.
HTTPBody
;
NSDictionary
*
requestBody
=
[
DoraemonUrlUtil
convertDicFromData
:
httpBody
];
DoraemonMockBaseModel
*
selectedApi
;
for
(
DoraemonMockBaseModel
*
api
in
dataArray
)
{
...
...
iOS/DoraemonKitDemo/DoraemonKitDemo/DemoVC/Net/ NSURLProtocol/DoraemonDemoURLProtocol1.m
浏览文件 @
84b08f1b
...
...
@@ -8,6 +8,7 @@
#import "DoraemonDemoURLProtocol1.h"
#import "DoraemonUrlUtil.h"
#import "DoraemonNetFlowManager.h"
static
NSString
*
const
kDoraemonDemoUrlProtocolKey
=
@"doraemon_demo_url_protocol_1_key"
;
...
...
@@ -48,10 +49,11 @@ static NSString * const kDoraemonDemoUrlProtocolKey = @"doraemon_demo_url_protoc
-
(
void
)
stopLoading
{
NSLog
(
@"11111 == stopLoading"
);
NSData
*
httpBody
=
[
DoraemonUrlUtil
getHttpBodyFromRequest
:
self
.
request
];
NSString
*
requestBody
=
[
DoraemonUrlUtil
convertJsonFromData
:
httpBody
];
NSLog
(
@"11111 == requestBody = %@"
,
requestBody
);
[
self
.
connection
cancel
];
[[
DoraemonNetFlowManager
shareInstance
]
httpBodyFromRequest
:
self
.
request
bodyCallBack
:
^
(
NSData
*
httpBody
)
{
NSString
*
requestBody
=
[
DoraemonUrlUtil
convertJsonFromData
:
httpBody
];
NSLog
(
@"11111 == requestBody = %@"
,
requestBody
);
[
self
.
connection
cancel
];
}];
}
...
...
iOS/DoraemonKitDemo/DoraemonKitDemo/DemoVC/Net/ NSURLProtocol/DoraemonDemoURLProtocol2.m
浏览文件 @
84b08f1b
...
...
@@ -8,6 +8,7 @@
#import "DoraemonDemoURLProtocol2.h"
#import "DoraemonUrlUtil.h"
#import "DoraemonNetFlowManager.h"
static
NSString
*
const
kDoraemonDemoUrlProtocol2Key
=
@"doraemon_demo_url_protocol_2_key"
;
...
...
@@ -48,10 +49,11 @@ static NSString * const kDoraemonDemoUrlProtocol2Key = @"doraemon_demo_url_proto
-
(
void
)
stopLoading
{
NSLog
(
@"22222 == stopLoading"
);
NSData
*
httpBody
=
[
DoraemonUrlUtil
getHttpBodyFromRequest
:
self
.
request
];
NSString
*
requestBody
=
[
DoraemonUrlUtil
convertJsonFromData
:
httpBody
];
NSLog
(
@"22222 == requestBody = %@"
,
requestBody
);
[
self
.
connection
cancel
];
[[
DoraemonNetFlowManager
shareInstance
]
httpBodyFromRequest
:
self
.
request
bodyCallBack
:
^
(
NSData
*
httpBody
)
{
NSString
*
requestBody
=
[
DoraemonUrlUtil
convertJsonFromData
:
httpBody
];
NSLog
(
@"22222 == requestBody = %@"
,
requestBody
);
[
self
.
connection
cancel
];
}];
}
...
...
iOS/DoraemonKitDemo/DoraemonKitDemo/DemoVC/Net/DoraemonDemoNetViewController.m
浏览文件 @
84b08f1b
...
...
@@ -222,10 +222,11 @@
session
.
requestSerializer
=
[
AFHTTPRequestSerializer
serializer
];
// 请求
session
.
responseSerializer
=
[
AFHTTPResponseSerializer
serializer
];
// 响应
session
.
responseSerializer
.
acceptableContentTypes
=
[
NSSet
setWithObjects
:
@"application/json"
,
@"text/json"
,
@"text/javascript"
,
@"text/html"
,
nil
];
[
session
GET
:
@"https://www.taobao.com/"
parameters
:
nil
success
:^
(
NSURLSessionDataTask
*
task
,
id
responseObject
)
{
[
session
GET
:
@"https://www.taobao.com/"
parameters
:
nil
headers
:
nil
progress
:
nil
success
:^
(
NSURLSessionDataTask
*
_Nonnull
task
,
id
_Nullable
responseObject
)
{
NSString
*
string
=
[[
NSString
alloc
]
initWithData
:
responseObject
encoding
:
NSUTF8StringEncoding
];
NSLog
(
@"success %@"
,
string
);
}
failure
:^
(
NSURLSessionDataTask
*
task
,
NSError
*
error
)
{
}
failure
:^
(
NSURLSessionDataTask
*
_Nullable
task
,
NSError
*
_Nonnull
error
)
{
NSLog
(
@"failure"
);
}];
...
...
@@ -238,7 +239,7 @@
}
-
(
void
)
netForAFNetworking2
{
AFHTTP
RequestOperationManager
*
manager
=
[
AFHTTPRequestOperat
ionManager
manager
];
AFHTTP
SessionManager
*
manager
=
[
AFHTTPSess
ionManager
manager
];
manager
.
requestSerializer
=
[
AFHTTPRequestSerializer
serializer
];
// 请求
manager
.
responseSerializer
=
[
AFHTTPResponseSerializer
serializer
];
// 响应
manager
.
responseSerializer
.
acceptableContentTypes
=
[
NSSet
setWithObjects
:
@"application/json"
,
@"text/json"
,
@"text/javascript"
,
@"text/html"
,
nil
];
...
...
@@ -249,10 +250,10 @@
// NSLog(@"请求失败");
// }];
[
manager
POST
:
@"https://www.taobao.com/"
parameters
:
nil
success
:^
(
AFHTTPRequestOperation
*
operation
,
id
responseObject
)
{
[
manager
POST
:
@"https://www.taobao.com/"
parameters
:
nil
headers
:
nil
progress
:
nil
success
:^
(
NSURLSessionDataTask
*
_Nonnull
task
,
id
_Nullable
responseObject
)
{
NSString
*
string
=
[[
NSString
alloc
]
initWithData
:
responseObject
encoding
:
NSUTF8StringEncoding
];
NSLog
(
@"success %@"
,
string
);
}
failure
:^
(
AFHTTPRequestOperation
*
operation
,
NSError
*
error
)
{
}
failure
:^
(
NSURLSessionDataTask
*
_Nullable
task
,
NSError
*
_Nonnull
error
)
{
NSLog
(
@"failure"
);
}];
}
...
...
iOS/DoraemonKitDemo/DoraemonKitDemo/DemoVC/Performance/DoraemonDemoPerformanceViewController.m
浏览文件 @
84b08f1b
...
...
@@ -130,14 +130,15 @@
// NSLog(@"请求失败");
// }];
AFHTTP
RequestOperationManager
*
manager
=
[
AFHTTPRequestOperat
ionManager
manager
];
AFHTTP
SessionManager
*
manager
=
[
AFHTTPSess
ionManager
manager
];
manager
.
requestSerializer
=
[
AFHTTPRequestSerializer
serializer
];
// 请求
manager
.
responseSerializer
=
[
AFHTTPResponseSerializer
serializer
];
// 响应
manager
.
responseSerializer
.
acceptableContentTypes
=
[
NSSet
setWithObjects
:
@"application/json"
,
@"text/json"
,
@"text/javascript"
,
@"text/html"
,
nil
];
[
manager
GET
:
@"https://www.taobao.com/"
parameters
:
nil
success
:^
(
AFHTTPRequestOperation
*
operation
,
id
responseObject
)
{
[
manager
GET
:
@"https://www.taobao.com/"
parameters
:
nil
headers
:
nil
progress
:
nil
success
:^
(
NSURLSessionDataTask
*
_Nonnull
task
,
id
_Nullable
responseObject
)
{
NSString
*
string
=
[[
NSString
alloc
]
initWithData
:
responseObject
encoding
:
NSUTF8StringEncoding
];
NSLog
(
@"request success %@"
,
string
);
}
failure
:^
(
AFHTTPRequestOperation
*
operation
,
NSError
*
error
)
{
}
failure
:^
(
NSURLSessionDataTask
*
_Nullable
task
,
NSError
*
_Nonnull
error
)
{
NSLog
(
@"request failure"
);
}];
}
...
...
iOS/DoraemonKitDemo/Podfile
浏览文件 @
84b08f1b
...
...
@@ -20,7 +20,7 @@ target :'DoraemonKitDemo' do
#pod 'DoraemonKit', :subspecs => ['Core','WithLogger','WithGPS','WithLoad','WithWeex', 'WithDatabase', 'WithMLeaksFinder'], :path => '../../'
#pod 'DoraemonKit', :subspecs => ['Core'], :path => '../../'
pod
'DoraemonKit'
,
:subspecs
=>
[
'Core'
,
'WithLogger'
,
'WithGPS'
,
'WithLoad'
,
'WithDatabase'
,
'WithMLeaksFinder'
,
'WithWeex'
],
:path
=>
'../../'
pod
'AFNetworking'
,
'2.6.3'
pod
'AFNetworking'
pod
'SDWebImage'
pod
'SocketRocket'
,
'~> 0.5'
pod
'SDWebImageWebPCoder'
...
...
iOS/DoraemonKitDemo/Podfile.lock
浏览文件 @
84b08f1b
PODS:
- AFNetworking (2.6.3):
- AFNetworking/NSURLConnection (= 2.6.3)
- AFNetworking/NSURLSession (= 2.6.3)
- AFNetworking/Reachability (= 2.6.3)
- AFNetworking/Security (= 2.6.3)
- AFNetworking/Serialization (= 2.6.3)
- AFNetworking/UIKit (= 2.6.3)
- AFNetworking/NSURLConnection (2.6.3):
- AFNetworking (4.0.1):
- AFNetworking/NSURLSession (= 4.0.1)
- AFNetworking/Reachability (= 4.0.1)
- AFNetworking/Security (= 4.0.1)
- AFNetworking/Serialization (= 4.0.1)
- AFNetworking/UIKit (= 4.0.1)
- AFNetworking/NSURLSession (4.0.1):
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/NSURLSession (2.6.3):
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/Reachability (2.6.3)
- AFNetworking/Security (2.6.3)
- AFNetworking/Serialization (2.6.3)
- AFNetworking/UIKit (2.6.3):
- AFNetworking/NSURLConnection
- AFNetworking/Reachability (4.0.1)
- AFNetworking/Security (4.0.1)
- AFNetworking/Serialization (4.0.1)
- AFNetworking/UIKit (4.0.1):
- AFNetworking/NSURLSession
- CocoaLumberjack (3.
6.2
):
- CocoaLumberjack/Core (= 3.
6.2
)
- CocoaLumberjack/Core (3.
6.2
)
- CocoaLumberjack (3.
7.0
):
- CocoaLumberjack/Core (= 3.
7.0
)
- CocoaLumberjack/Core (3.
7.0
)
- DoraemonKit/Core (3.0.6):
- FMDB
- GCDWebServer
...
...
@@ -65,12 +59,12 @@ PODS:
- libwebp/mux (1.1.0):
- libwebp/demux
- libwebp/webp (1.1.0)
- SDWebImage (5.
8
.4):
- SDWebImage/Core (= 5.
8
.4)
- SDWebImage/Core (5.
8
.4)
- SDWebImageWebPCoder (0.
6.1
):
- SDWebImage (5.
10
.4):
- SDWebImage/Core (= 5.
10
.4)
- SDWebImage/Core (5.
10
.4)
- SDWebImageWebPCoder (0.
8.2
):
- libwebp (~> 1.0)
- SDWebImage/Core (~> 5.
7
)
- SDWebImage/Core (~> 5.
10
)
- SocketRocket (0.5.1)
- WeexSDK (0.28.0)
- WXDevtool (0.24.0):
...
...
@@ -81,7 +75,7 @@ PODS:
- GCDWebServer
DEPENDENCIES:
- AFNetworking
(= 2.6.3)
- AFNetworking
- DoraemonKit/Core (from `../../`)
- DoraemonKit/WithDatabase (from `../../`)
- DoraemonKit/WithGPS (from `../../`)
...
...
@@ -118,27 +112,27 @@ EXTERNAL SOURCES:
CHECKOUT OPTIONS:
FBRetainCycleDetector:
:commit:
1ff2adee84a6ee94a1ae82526104a188774eb90a
:commit:
32c4afc1fc17553f9b69e4edd82cfa3c73dbb331
:git: https://github.com/facebook/FBRetainCycleDetector.git
YYDebugDatabase:
:commit: 87f4214ab9656b75dd74dfcc042cc3b5067ebab6
:git: https://github.com/y500/YYDebugDatabase.git
SPEC CHECKSUMS:
AFNetworking:
cb8d14a848e831097108418f5d49217339d4eb60
CocoaLumberjack:
bd155f2dd06c0e0b03f876f7a3ee55693122ec94
AFNetworking:
7864c38297c79aaca1500c33288e429c3451fdce
CocoaLumberjack:
e8955b9d337ac307103b0a34fd141c32f27e53c5
DoraemonKit: 919709427c30af94e265532a879ac41797d296d1
FBRetainCycleDetector: 46daef95c2dfa9be34b53087edf6a8f34e4c749c
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4
libwebp: 946cb3063cea9236285f7e9a8505d806d30e07f3
SDWebImage: c
f6922231e95550934da2ada0f20f2becf2ceba9
SDWebImageWebPCoder:
d0dac55073088d24b2ac1b191a71a8f8d0adac21
SDWebImage: c
666b97e1fa9c64b4909816a903322018f0a9c84
SDWebImageWebPCoder:
f56ab499e3ea57dfeb6c3187dce183b10e160db0
SocketRocket: d57c7159b83c3c6655745cd15302aa24b6bae531
WeexSDK: 78861d2f8b78f67e30580c15a54f5b420456db39
WXDevtool: 95b70c73c06fc3299d65bd53ba4b3e0b0087f3cb
YYDebugDatabase: e684a7f79fca2e3673a23347cefb822f911f3124
PODFILE CHECKSUM:
6c5cced982a83d1a6dbfb6e8501724985d70d130
PODFILE CHECKSUM:
a955cdaf3e59b0dc21224f229ea928cf97cc0173
COCOAPODS: 1.
10.1
COCOAPODS: 1.
8.4
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录