Compare commits
93 Commits
add-compat
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
555385d2b8 | ||
|
|
2da270be61 | ||
|
|
0fba527112 | ||
|
|
4743faa83c | ||
|
|
eb9ce0e23d | ||
|
|
5cf601ce0c | ||
|
|
006e896fbc | ||
|
|
9dcc6efd85 | ||
|
|
2c2d2c3062 | ||
|
|
7383ffc61f | ||
|
|
023cec7994 | ||
|
|
685e31a31b | ||
|
|
b3c4a78aca | ||
|
|
ee950948f2 | ||
|
|
9cc782931a | ||
|
|
3517a1d23c | ||
|
|
5890adc404 | ||
|
|
ba4238910e | ||
|
|
d6db8307d9 | ||
|
|
27608c91d0 | ||
|
|
1bd73c7fca | ||
|
|
59e92b18c6 | ||
|
|
fdbec013c4 | ||
|
|
99cda82d33 | ||
|
|
e46e64c274 | ||
|
|
390e8fa6d4 | ||
|
|
dea4316db0 | ||
|
|
23a6f442c8 | ||
|
|
9bb8ea7452 | ||
|
|
af23240a4b | ||
|
|
0579f71d5a | ||
|
|
864c8d6aed | ||
|
|
7b48feb383 | ||
|
|
3c54e1f8a5 | ||
|
|
a8758d26d5 | ||
|
|
64795368ae | ||
|
|
86c8cc2263 | ||
|
|
b892e566f9 | ||
|
|
12088d6d37 | ||
|
|
a24b4896bb | ||
|
|
a101152743 | ||
|
|
5b92ed3368 | ||
|
|
17edb8138a | ||
|
|
7ff008b872 | ||
|
|
619a65b57e | ||
|
|
91cc666887 | ||
|
|
926d4dbb8b | ||
|
|
5544ef03f4 | ||
|
|
ffbcabeb58 | ||
|
|
7642bcf659 | ||
|
|
9c2742c868 | ||
|
|
5fe5ea3355 | ||
|
|
d135b740da | ||
|
|
342653f27e | ||
|
|
06079adbe4 | ||
|
|
1c52c76537 | ||
|
|
1d1c0241a9 | ||
|
|
ca380fdcfc | ||
|
|
54f11357d7 | ||
|
|
6622b05771 | ||
|
|
63410f3567 | ||
|
|
d0448a80f4 | ||
|
|
c4caddc5e9 | ||
|
|
aed00d3099 | ||
|
|
fba4f366d2 | ||
|
|
ad7b31f4f9 | ||
|
|
009e3bb667 | ||
|
|
d768f1c7c5 | ||
|
|
684dfe05d8 | ||
|
|
41782ab4d6 | ||
|
|
850974c941 | ||
|
|
61e15f412b | ||
|
|
b15888735a | ||
|
|
48b63fa252 | ||
|
|
447d7f3c58 | ||
|
|
207a707fa3 | ||
|
|
357466d102 | ||
|
|
746f6c3a1e | ||
|
|
6897b06049 | ||
|
|
29021d2eeb | ||
|
|
e6c674ed84 | ||
|
|
1f70ba85bb | ||
|
|
2d19dc8540 | ||
|
|
5e19a4df0b | ||
|
|
ded6a76946 | ||
|
|
c976cf3db8 | ||
|
|
d8f45e79e5 | ||
|
|
1e03fb1a72 | ||
|
|
75763005cb | ||
|
|
849dff7dee | ||
|
|
27c819537a | ||
|
|
c18c09a75c | ||
|
|
f8159fee72 |
2
.codecov.yml
Normal file
2
.codecov.yml
Normal file
@ -0,0 +1,2 @@
|
||||
ignore:
|
||||
- "Tests"
|
||||
31
.travis.yml
31
.travis.yml
@ -1,5 +1,5 @@
|
||||
language: objective-c
|
||||
osx_image: xcode7.1
|
||||
osx_image: xcode11
|
||||
sudo: false
|
||||
env:
|
||||
global:
|
||||
@ -9,32 +9,29 @@ env:
|
||||
- FASTLANE_LANE=ci_commit
|
||||
matrix:
|
||||
include:
|
||||
- osx_image: xcode9.3
|
||||
- osx_image: xcode11
|
||||
env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default
|
||||
- osx_image: xcode11
|
||||
env: FASTLANE_ENV=ios13_xcode11
|
||||
- osx_image: xcode11
|
||||
env: FASTLANE_ENV=tvos13_xcode11
|
||||
- osx_image: xcode11
|
||||
env: FASTLANE_ENV=osx
|
||||
- osx_image: xcode10
|
||||
env: FASTLANE_ENV=ios12_xcode10
|
||||
- osx_image: xcode9.4
|
||||
env: FASTLANE_ENV=ios11_xcode94
|
||||
- osx_image: xcode9.3
|
||||
env: FASTLANE_ENV=ios11_xcode93
|
||||
- osx_image: xcode9.3
|
||||
env: FASTLANE_ENV=tvos11_xcode9
|
||||
- osx_image: xcode9.3
|
||||
env: FASTLANE_ENV=osx
|
||||
- osx_image: xcode9.2
|
||||
env: FASTLANE_ENV=ios11_xcode92
|
||||
- osx_image: xcode9.1
|
||||
env: FASTLANE_ENV=ios11_xcode91
|
||||
- osx_image: xcode9
|
||||
env: FASTLANE_ENV=ios11_xcode9
|
||||
- osx_image: xcode8.3
|
||||
env: FASTLANE_ENV=ios10_xcode8
|
||||
- osx_image: xcode7.3
|
||||
env: FASTLANE_ENV=ios9_xcode7
|
||||
- osx_image: xcode7.3
|
||||
env: FASTLANE_ENV=ios8_xcode7
|
||||
before_install:
|
||||
# Force bundler 1.12.5 because version 1.13 has issues, see https://github.com/fastlane/fastlane/issues/6065#issuecomment-246044617
|
||||
- gem uninstall bundler -v '>1.12.5' --force --executables || echo "bundler >1.12.5 is not installed"
|
||||
- gem install bundler -v 1.12.5 --no-rdoc --no-ri --no-document --quiet
|
||||
- gem install fastlane --no-rdoc --no-ri --no-document --quiet
|
||||
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
|
||||
- gem install fastlane --no-document --quiet
|
||||
- gem install cocoapods --no-document --quiet
|
||||
script:
|
||||
- set -o pipefail
|
||||
- fastlane $FASTLANE_LANE configuration:Debug --env $FASTLANE_ENV
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'AFNetworking'
|
||||
s.version = '3.2.0'
|
||||
s.version = '3.2.1'
|
||||
s.license = 'MIT'
|
||||
s.summary = 'A delightful iOS and OS X networking framework.'
|
||||
s.homepage = 'https://github.com/AFNetworking/AFNetworking'
|
||||
@ -10,7 +10,7 @@ Pod::Spec.new do |s|
|
||||
s.requires_arc = true
|
||||
|
||||
s.public_header_files = 'AFNetworking/AFNetworking.h'
|
||||
s.source_files = 'AFNetworking/AFNetworking.h', 'AFNetworking/AFCompatibilityMacros.h'
|
||||
s.source_files = 'AFNetworking/AFNetworking.h'
|
||||
|
||||
pch_AF = <<-EOS
|
||||
#ifndef TARGET_OS_IOS
|
||||
@ -27,7 +27,7 @@ Pod::Spec.new do |s|
|
||||
EOS
|
||||
s.prefix_header_contents = pch_AF
|
||||
|
||||
s.ios.deployment_target = '7.0'
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.osx.deployment_target = '10.9'
|
||||
s.watchos.deployment_target = '2.0'
|
||||
s.tvos.deployment_target = '9.0'
|
||||
@ -47,7 +47,7 @@ EOS
|
||||
end
|
||||
|
||||
s.subspec 'Reachability' do |ss|
|
||||
ss.ios.deployment_target = '7.0'
|
||||
ss.ios.deployment_target = '8.0'
|
||||
ss.osx.deployment_target = '10.9'
|
||||
ss.tvos.deployment_target = '9.0'
|
||||
|
||||
@ -64,12 +64,12 @@ EOS
|
||||
ss.tvos.dependency 'AFNetworking/Reachability'
|
||||
ss.dependency 'AFNetworking/Security'
|
||||
|
||||
ss.source_files = 'AFNetworking/AF{URL,HTTP}SessionManager.{h,m}'
|
||||
ss.public_header_files = 'AFNetworking/AF{URL,HTTP}SessionManager.h'
|
||||
ss.source_files = 'AFNetworking/AF{URL,HTTP}SessionManager.{h,m}', 'AFNetworking/AFCompatibilityMacros.h'
|
||||
ss.public_header_files = 'AFNetworking/AF{URL,HTTP}SessionManager.h', 'AFNetworking/AFCompatibilityMacros.h'
|
||||
end
|
||||
|
||||
s.subspec 'UIKit' do |ss|
|
||||
ss.ios.deployment_target = '7.0'
|
||||
ss.ios.deployment_target = '8.0'
|
||||
ss.tvos.deployment_target = '9.0'
|
||||
ss.dependency 'AFNetworking/NSURLSession'
|
||||
|
||||
|
||||
@ -10,19 +10,13 @@
|
||||
1BF9F9601C87832B00F1F35A /* AFImageResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BF9F95F1C87832B00F1F35A /* AFImageResponseSerializerTests.m */; };
|
||||
1BF9F9611C87843200F1F35A /* AFImageResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BF9F95F1C87832B00F1F35A /* AFImageResponseSerializerTests.m */; };
|
||||
1BF9F9621C87843300F1F35A /* AFImageResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BF9F95F1C87832B00F1F35A /* AFImageResponseSerializerTests.m */; };
|
||||
1F6F7DF71F17051000C979D0 /* DST Root CA X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */; };
|
||||
1F6F7DF81F17051000C979D0 /* Let's Encrypt Authority X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */; };
|
||||
1F6F7DFA1F17051000C979D0 /* DST Root CA X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */; };
|
||||
1F6F7DFB1F17051000C979D0 /* Let's Encrypt Authority X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */; };
|
||||
1F6F7DFD1F17051100C979D0 /* DST Root CA X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */; };
|
||||
1F6F7DFE1F17051100C979D0 /* Let's Encrypt Authority X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */; };
|
||||
1F8482C0220F386200718111 /* httpbinorg_03172020.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F8482BF220F386200718111 /* httpbinorg_03172020.cer */; };
|
||||
1F8482C1220F386200718111 /* httpbinorg_03172020.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F8482BF220F386200718111 /* httpbinorg_03172020.cer */; };
|
||||
1F8482C2220F386200718111 /* httpbinorg_03172020.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F8482BF220F386200718111 /* httpbinorg_03172020.cer */; };
|
||||
1F96D2A4203649560085FC3F /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
1F96D2A5203649570085FC3F /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
1F96D2A6203649570085FC3F /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
1F96D2A7203649580085FC3F /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
1FBBC1C9207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1FBBC1C8207D5F8F00631B47 /* httpbinorg_06102018.cer */; };
|
||||
1FBBC1CA207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1FBBC1C8207D5F8F00631B47 /* httpbinorg_06102018.cer */; };
|
||||
1FBBC1CB207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1FBBC1C8207D5F8F00631B47 /* httpbinorg_06102018.cer */; };
|
||||
2960BAC31C1B2F1A00BA02F0 /* AFUIButtonTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2960BAC21C1B2F1A00BA02F0 /* AFUIButtonTests.m */; };
|
||||
297824A31BC2D69A0041C395 /* adn_0.cer in Resources */ = {isa = PBXBuildFile; fileRef = 297824A01BC2D69A0041C395 /* adn_0.cer */; };
|
||||
297824A41BC2D69A0041C395 /* adn_0.cer in Resources */ = {isa = PBXBuildFile; fileRef = 297824A01BC2D69A0041C395 /* adn_0.cer */; };
|
||||
@ -202,6 +196,15 @@
|
||||
5F4323DD1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */ = {isa = PBXBuildFile; fileRef = 5F4323DC1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer */; };
|
||||
5F4323DE1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */ = {isa = PBXBuildFile; fileRef = 5F4323DC1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer */; };
|
||||
5F4323DF1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */ = {isa = PBXBuildFile; fileRef = 5F4323DC1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer */; };
|
||||
E2B10D8E233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8B233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer */; };
|
||||
E2B10D8F233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8B233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer */; };
|
||||
E2B10D90233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8B233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer */; };
|
||||
E2B10D91233035100004E005 /* Amazon Root CA 1.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8C233035100004E005 /* Amazon Root CA 1.cer */; };
|
||||
E2B10D92233035100004E005 /* Amazon Root CA 1.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8C233035100004E005 /* Amazon Root CA 1.cer */; };
|
||||
E2B10D93233035100004E005 /* Amazon Root CA 1.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8C233035100004E005 /* Amazon Root CA 1.cer */; };
|
||||
E2B10D94233035100004E005 /* Amazon.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8D233035100004E005 /* Amazon.cer */; };
|
||||
E2B10D95233035100004E005 /* Amazon.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8D233035100004E005 /* Amazon.cer */; };
|
||||
E2B10D96233035100004E005 /* Amazon.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8D233035100004E005 /* Amazon.cer */; };
|
||||
E91164651DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E91164641DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m */; };
|
||||
E91164661DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E91164641DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m */; };
|
||||
E91164671DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E91164641DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m */; };
|
||||
@ -234,9 +237,7 @@
|
||||
/* Begin PBXFileReference section */
|
||||
1BF9F95F1C87832B00F1F35A /* AFImageResponseSerializerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFImageResponseSerializerTests.m; sourceTree = "<group>"; };
|
||||
1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AFCompatibilityMacros.h; sourceTree = "<group>"; };
|
||||
1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Let's Encrypt Authority X3.cer"; sourceTree = "<group>"; };
|
||||
1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DST Root CA X3.cer"; sourceTree = "<group>"; };
|
||||
1FBBC1C8207D5F8F00631B47 /* httpbinorg_06102018.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = httpbinorg_06102018.cer; sourceTree = "<group>"; };
|
||||
1F8482BF220F386200718111 /* httpbinorg_03172020.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = httpbinorg_03172020.cer; sourceTree = "<group>"; };
|
||||
2960BAC21C1B2F1A00BA02F0 /* AFUIButtonTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFUIButtonTests.m; sourceTree = "<group>"; };
|
||||
297824A01BC2D69A0041C395 /* adn_0.cer */ = {isa = PBXFileReference; lastKnownFileType = file; name = adn_0.cer; path = ADNNetServerTrustChain/adn_0.cer; sourceTree = "<group>"; };
|
||||
297824A11BC2D69A0041C395 /* adn_1.cer */ = {isa = PBXFileReference; lastKnownFileType = file; name = adn_1.cer; path = ADNNetServerTrustChain/adn_1.cer; sourceTree = "<group>"; };
|
||||
@ -315,6 +316,9 @@
|
||||
5F4323D41BF63CB0003B8749 /* GoogleComServerTrustChainPath1 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = GoogleComServerTrustChainPath1; sourceTree = "<group>"; };
|
||||
5F4323D81BF63CBA003B8749 /* GoogleComServerTrustChainPath2 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = GoogleComServerTrustChainPath2; sourceTree = "<group>"; };
|
||||
5F4323DC1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = GeoTrust_Global_CA_Root.cer; sourceTree = "<group>"; };
|
||||
E2B10D8B233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Starfield Services Root Certificate Authority - G2.cer"; sourceTree = "<group>"; };
|
||||
E2B10D8C233035100004E005 /* Amazon Root CA 1.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Amazon Root CA 1.cer"; sourceTree = "<group>"; };
|
||||
E2B10D8D233035100004E005 /* Amazon.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = Amazon.cer; sourceTree = "<group>"; };
|
||||
E91164641DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFPropertyListRequestSerializerTests.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -409,10 +413,11 @@
|
||||
298D7C6D1BC2C88F00FD3B3E /* HTTPBin.org */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E2B10D8C233035100004E005 /* Amazon Root CA 1.cer */,
|
||||
E2B10D8D233035100004E005 /* Amazon.cer */,
|
||||
E2B10D8B233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer */,
|
||||
298D7CE21BC2CB7C00FD3B3E /* HTTPBinOrgServerTrustChain */,
|
||||
1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */,
|
||||
1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */,
|
||||
1FBBC1C8207D5F8F00631B47 /* httpbinorg_06102018.cer */,
|
||||
1F8482BF220F386200718111 /* httpbinorg_03172020.cer */,
|
||||
);
|
||||
path = HTTPBin.org;
|
||||
sourceTree = "<group>";
|
||||
@ -851,7 +856,8 @@
|
||||
files = (
|
||||
2987B0DE1BC40AFB00179A4C /* foobar.com.cer in Resources */,
|
||||
2987B0D61BC40AEC00179A4C /* ADNNetServerTrustChain in Resources */,
|
||||
1FBBC1CB207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */,
|
||||
E2B10D90233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */,
|
||||
1F8482C2220F386200718111 /* httpbinorg_03172020.cer in Resources */,
|
||||
2987B0DF1BC40AFB00179A4C /* NoDomains.cer in Resources */,
|
||||
2987B0D41BC40AE900179A4C /* adn_1.cer in Resources */,
|
||||
2987B0DD1BC40AFB00179A4C /* AltName.cer in Resources */,
|
||||
@ -860,12 +866,12 @@
|
||||
2987B0DC1BC40AF600179A4C /* logo.png in Resources */,
|
||||
2987B0D51BC40AE900179A4C /* adn_2.cer in Resources */,
|
||||
5F4323D71BF63CB0003B8749 /* GoogleComServerTrustChainPath1 in Resources */,
|
||||
1F6F7DFE1F17051100C979D0 /* Let's Encrypt Authority X3.cer in Resources */,
|
||||
E2B10D96233035100004E005 /* Amazon.cer in Resources */,
|
||||
5F4323DB1BF63CBA003B8749 /* GoogleComServerTrustChainPath2 in Resources */,
|
||||
5F4323BD1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */,
|
||||
5F4323DF1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */,
|
||||
E2B10D93233035100004E005 /* Amazon Root CA 1.cer in Resources */,
|
||||
5F4323C01BF63741003B8749 /* GeoTrust_Global_CA-cross.cer in Resources */,
|
||||
1F6F7DFD1F17051100C979D0 /* DST Root CA X3.cer in Resources */,
|
||||
5F4323CF1BF63741003B8749 /* GoogleInternetAuthorityG2.cer in Resources */,
|
||||
5F4323C31BF63741003B8749 /* google.com.cer in Resources */,
|
||||
);
|
||||
@ -877,7 +883,8 @@
|
||||
files = (
|
||||
298D7CBF1BC2CA9D00FD3B3E /* foobar.com.cer in Resources */,
|
||||
298D7CBA1BC2CA9800FD3B3E /* logo.png in Resources */,
|
||||
1FBBC1C9207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */,
|
||||
E2B10D8E233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */,
|
||||
1F8482C0220F386200718111 /* httpbinorg_03172020.cer in Resources */,
|
||||
297824A31BC2D69A0041C395 /* adn_0.cer in Resources */,
|
||||
298D7CE31BC2CB7C00FD3B3E /* HTTPBinOrgServerTrustChain in Resources */,
|
||||
297824A71BC2D69A0041C395 /* adn_2.cer in Resources */,
|
||||
@ -886,12 +893,12 @@
|
||||
298D7CE01BC2CB5A00FD3B3E /* ADNNetServerTrustChain in Resources */,
|
||||
298D7CBE1BC2CA9D00FD3B3E /* AltName.cer in Resources */,
|
||||
5F4323D51BF63CB0003B8749 /* GoogleComServerTrustChainPath1 in Resources */,
|
||||
1F6F7DF81F17051000C979D0 /* Let's Encrypt Authority X3.cer in Resources */,
|
||||
E2B10D94233035100004E005 /* Amazon.cer in Resources */,
|
||||
5F4323D91BF63CBA003B8749 /* GoogleComServerTrustChainPath2 in Resources */,
|
||||
5F4323BB1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */,
|
||||
5F4323DD1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */,
|
||||
E2B10D91233035100004E005 /* Amazon Root CA 1.cer in Resources */,
|
||||
5F4323BE1BF63741003B8749 /* GeoTrust_Global_CA-cross.cer in Resources */,
|
||||
1F6F7DF71F17051000C979D0 /* DST Root CA X3.cer in Resources */,
|
||||
5F4323CD1BF63741003B8749 /* GoogleInternetAuthorityG2.cer in Resources */,
|
||||
5F4323C11BF63741003B8749 /* google.com.cer in Resources */,
|
||||
);
|
||||
@ -903,7 +910,8 @@
|
||||
files = (
|
||||
298D7CBC1BC2CA9C00FD3B3E /* foobar.com.cer in Resources */,
|
||||
298D7CB91BC2CA9800FD3B3E /* logo.png in Resources */,
|
||||
1FBBC1CA207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */,
|
||||
E2B10D8F233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */,
|
||||
1F8482C1220F386200718111 /* httpbinorg_03172020.cer in Resources */,
|
||||
297824A41BC2D69A0041C395 /* adn_0.cer in Resources */,
|
||||
298D7CE41BC2CB7C00FD3B3E /* HTTPBinOrgServerTrustChain in Resources */,
|
||||
297824A81BC2D69A0041C395 /* adn_2.cer in Resources */,
|
||||
@ -912,12 +920,12 @@
|
||||
298D7CE11BC2CB5A00FD3B3E /* ADNNetServerTrustChain in Resources */,
|
||||
298D7CBB1BC2CA9C00FD3B3E /* AltName.cer in Resources */,
|
||||
5F4323D61BF63CB0003B8749 /* GoogleComServerTrustChainPath1 in Resources */,
|
||||
1F6F7DFB1F17051000C979D0 /* Let's Encrypt Authority X3.cer in Resources */,
|
||||
E2B10D95233035100004E005 /* Amazon.cer in Resources */,
|
||||
5F4323DA1BF63CBA003B8749 /* GoogleComServerTrustChainPath2 in Resources */,
|
||||
5F4323BC1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */,
|
||||
5F4323CE1BF63741003B8749 /* GoogleInternetAuthorityG2.cer in Resources */,
|
||||
E2B10D92233035100004E005 /* Amazon Root CA 1.cer in Resources */,
|
||||
5F4323DE1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */,
|
||||
1F6F7DFA1F17051000C979D0 /* DST Root CA X3.cer in Resources */,
|
||||
5F4323BF1BF63741003B8749 /* GeoTrust_Global_CA-cross.cer in Resources */,
|
||||
5F4323C21BF63741003B8749 /* google.com.cer in Resources */,
|
||||
);
|
||||
@ -1255,6 +1263,7 @@
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_CODE_COVERAGE = YES;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_ASSIGN_ENUM = YES;
|
||||
@ -1335,6 +1344,7 @@
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_CODE_COVERAGE = NO;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_ASSIGN_ENUM = YES;
|
||||
|
||||
@ -34,4 +34,10 @@
|
||||
#define AF_CAN_USE_AT_AVAILABLE 0
|
||||
#endif
|
||||
|
||||
#if ((__IPHONE_OS_VERSION_MAX_ALLOWED && __IPHONE_OS_VERSION_MAX_ALLOWED < 100000) || (__MAC_OS_VERSION_MAX_ALLOWED && __MAC_OS_VERSION_MAX_ALLOWED < 101200) ||(__WATCH_OS_MAX_VERSION_ALLOWED && __WATCH_OS_MAX_VERSION_ALLOWED < 30000) ||(__TV_OS_MAX_VERSION_ALLOWED && __TV_OS_MAX_VERSION_ALLOWED < 100000))
|
||||
#define AF_CAN_INCLUDE_SESSION_TASK_METRICS 0
|
||||
#else
|
||||
#define AF_CAN_INCLUDE_SESSION_TASK_METRICS 1
|
||||
#endif
|
||||
|
||||
#endif /* AFCompatibilityMacros_h */
|
||||
|
||||
@ -167,6 +167,25 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `GET` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
@ -184,7 +203,24 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `HEAD` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `POST` request.
|
||||
@ -214,6 +250,25 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `POST` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
@ -249,6 +304,26 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
|
||||
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
|
||||
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
|
||||
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
@ -267,7 +342,24 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `PUT` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `PATCH` request.
|
||||
@ -282,7 +374,24 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `PATCH` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `DELETE` request.
|
||||
@ -297,7 +406,24 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
Creates and runs an `NSURLSessionDataTask` with a `DELETE` request.
|
||||
|
||||
@param URLString The URL string used to create the request URL.
|
||||
@param parameters The parameters to be encoded according to the client request serializer.
|
||||
@param headers The headers appended to the default headers for this request.
|
||||
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
|
||||
@param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
|
||||
|
||||
@see -dataTaskWithRequest:completionHandler:
|
||||
*/
|
||||
- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@
|
||||
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||
{
|
||||
|
||||
return [self GET:URLString parameters:parameters progress:nil success:success failure:failure];
|
||||
return [self GET:URLString parameters:parameters headers:nil progress:nil success:success failure:failure];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)GET:(NSString *)URLString
|
||||
@ -133,16 +133,28 @@
|
||||
failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
|
||||
{
|
||||
|
||||
return [self GET:URLString parameters:parameters headers:nil progress:downloadProgress success:success failure:failure];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)GET:(NSString *)URLString
|
||||
parameters:(id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
progress:(void (^)(NSProgress * _Nonnull))downloadProgress
|
||||
success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
|
||||
failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
|
||||
{
|
||||
|
||||
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET"
|
||||
URLString:URLString
|
||||
parameters:parameters
|
||||
headers:headers
|
||||
uploadProgress:nil
|
||||
downloadProgress:downloadProgress
|
||||
success:success
|
||||
failure:failure];
|
||||
|
||||
|
||||
[dataTask resume];
|
||||
|
||||
|
||||
return dataTask;
|
||||
}
|
||||
|
||||
@ -151,14 +163,23 @@
|
||||
success:(void (^)(NSURLSessionDataTask *task))success
|
||||
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||
{
|
||||
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:^(NSURLSessionDataTask *task, __unused id responseObject) {
|
||||
return [self HEAD:URLString parameters:parameters headers:nil success:success failure:failure];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)HEAD:(NSString *)URLString
|
||||
parameters:(id)parameters
|
||||
headers:(NSDictionary<NSString *,NSString *> *)headers
|
||||
success:(void (^)(NSURLSessionDataTask * _Nonnull))success
|
||||
failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
|
||||
{
|
||||
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:^(NSURLSessionDataTask *task, __unused id responseObject) {
|
||||
if (success) {
|
||||
success(task);
|
||||
}
|
||||
} failure:failure];
|
||||
|
||||
|
||||
[dataTask resume];
|
||||
|
||||
|
||||
return dataTask;
|
||||
}
|
||||
|
||||
@ -167,7 +188,7 @@
|
||||
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||
{
|
||||
return [self POST:URLString parameters:parameters progress:nil success:success failure:failure];
|
||||
return [self POST:URLString parameters:parameters headers:nil progress:nil success:success failure:failure];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||
@ -176,10 +197,20 @@
|
||||
success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
|
||||
failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
|
||||
{
|
||||
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters uploadProgress:uploadProgress downloadProgress:nil success:success failure:failure];
|
||||
return [self POST:URLString parameters:parameters headers:nil progress:uploadProgress success:success failure:failure];
|
||||
}
|
||||
|
||||
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||
parameters:(nullable id)parameters
|
||||
headers:(nullable NSDictionary <NSString *, NSString *> *)headers
|
||||
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure
|
||||
{
|
||||
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters headers:headers uploadProgress:uploadProgress downloadProgress:nil success:success failure:failure];
|
||||
|
||||
[dataTask resume];
|
||||
|
||||
|
||||
return dataTask;
|
||||
}
|
||||
|
||||
@ -189,7 +220,7 @@
|
||||
success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
|
||||
{
|
||||
return [self POST:URLString parameters:parameters constructingBodyWithBlock:block progress:nil success:success failure:failure];
|
||||
return [self POST:URLString parameters:parameters headers:nil constructingBodyWithBlock:block progress:nil success:success failure:failure];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||
@ -198,19 +229,32 @@
|
||||
progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgress
|
||||
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||
{
|
||||
return [self POST:URLString parameters:parameters headers:nil constructingBodyWithBlock:block progress:uploadProgress success:success failure:failure];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)POST:(NSString *)URLString
|
||||
parameters:(id)parameters
|
||||
headers:(NSDictionary<NSString *,NSString *> *)headers
|
||||
constructingBodyWithBlock:(void (^)(id<AFMultipartFormData> _Nonnull))block
|
||||
progress:(void (^)(NSProgress * _Nonnull))uploadProgress
|
||||
success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
|
||||
{
|
||||
NSError *serializationError = nil;
|
||||
NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError];
|
||||
for (NSString *headerField in headers.keyEnumerator) {
|
||||
[request addValue:headers[headerField] forHTTPHeaderField:headerField];
|
||||
}
|
||||
if (serializationError) {
|
||||
if (failure) {
|
||||
dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
|
||||
failure(nil, serializationError);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
__block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:uploadProgress completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
|
||||
if (error) {
|
||||
if (failure) {
|
||||
@ -222,9 +266,9 @@
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
[task resume];
|
||||
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
@ -233,10 +277,19 @@
|
||||
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||
{
|
||||
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
|
||||
return [self PUT:URLString parameters:parameters headers:nil success:success failure:failure];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)PUT:(NSString *)URLString
|
||||
parameters:(id)parameters
|
||||
headers:(NSDictionary<NSString *,NSString *> *)headers
|
||||
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||
{
|
||||
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:success failure:failure];
|
||||
|
||||
[dataTask resume];
|
||||
|
||||
|
||||
return dataTask;
|
||||
}
|
||||
|
||||
@ -245,10 +298,19 @@
|
||||
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||
{
|
||||
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
|
||||
return [self PATCH:URLString parameters:parameters headers:nil success:success failure:failure];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)PATCH:(NSString *)URLString
|
||||
parameters:(id)parameters
|
||||
headers:(NSDictionary<NSString *,NSString *> *)headers
|
||||
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||
{
|
||||
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:success failure:failure];
|
||||
|
||||
[dataTask resume];
|
||||
|
||||
|
||||
return dataTask;
|
||||
}
|
||||
|
||||
@ -257,16 +319,26 @@
|
||||
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||
{
|
||||
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
|
||||
return [self DELETE:URLString parameters:parameters headers:nil success:success failure:failure];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)DELETE:(NSString *)URLString
|
||||
parameters:(id)parameters
|
||||
headers:(NSDictionary<NSString *,NSString *> *)headers
|
||||
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
|
||||
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
|
||||
{
|
||||
NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:success failure:failure];
|
||||
|
||||
[dataTask resume];
|
||||
|
||||
|
||||
return dataTask;
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method
|
||||
URLString:(NSString *)URLString
|
||||
parameters:(id)parameters
|
||||
headers:(NSDictionary <NSString *, NSString *> *)headers
|
||||
uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgress
|
||||
downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgress
|
||||
success:(void (^)(NSURLSessionDataTask *, id))success
|
||||
@ -274,6 +346,9 @@
|
||||
{
|
||||
NSError *serializationError = nil;
|
||||
NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError];
|
||||
for (NSString *headerField in headers.keyEnumerator) {
|
||||
[request addValue:headers[headerField] forHTTPHeaderField:headerField];
|
||||
}
|
||||
if (serializationError) {
|
||||
if (failure) {
|
||||
dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
|
||||
|
||||
@ -32,6 +32,7 @@ NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire
|
||||
NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem";
|
||||
|
||||
typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status);
|
||||
typedef AFNetworkReachabilityManager * (^AFNetworkReachabilityStatusCallback)(AFNetworkReachabilityStatus status);
|
||||
|
||||
NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) {
|
||||
switch (status) {
|
||||
@ -78,20 +79,21 @@ static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetwork
|
||||
* a queued notification (for an earlier status condition) is processed after
|
||||
* the later update, resulting in the listener being left in the wrong state.
|
||||
*/
|
||||
static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block) {
|
||||
static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusCallback block) {
|
||||
AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
AFNetworkReachabilityManager *manager = nil;
|
||||
if (block) {
|
||||
block(status);
|
||||
manager = block(status);
|
||||
}
|
||||
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) };
|
||||
[notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo];
|
||||
[notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:manager userInfo:userInfo];
|
||||
});
|
||||
}
|
||||
|
||||
static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
|
||||
AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info);
|
||||
AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusCallback)info);
|
||||
}
|
||||
|
||||
|
||||
@ -210,14 +212,15 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
|
||||
}
|
||||
|
||||
__weak __typeof(self)weakSelf = self;
|
||||
AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) {
|
||||
AFNetworkReachabilityStatusCallback callback = ^(AFNetworkReachabilityStatus status) {
|
||||
__strong __typeof(weakSelf)strongSelf = weakSelf;
|
||||
|
||||
strongSelf.networkReachabilityStatus = status;
|
||||
if (strongSelf.networkReachabilityStatusBlock) {
|
||||
strongSelf.networkReachabilityStatusBlock(status);
|
||||
}
|
||||
|
||||
|
||||
return strongSelf;
|
||||
};
|
||||
|
||||
SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL};
|
||||
|
||||
@ -45,10 +45,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
The certificates used to evaluate server trust according to the SSL pinning mode.
|
||||
|
||||
By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`.
|
||||
|
||||
Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
|
||||
|
||||
@see policyWithPinningMode:withPinnedCertificates:
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) NSSet <NSData *> *pinnedCertificates;
|
||||
|
||||
@ -90,10 +90,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Creates and returns a security policy with the specified pinning mode.
|
||||
|
||||
Certificates with the `.cer` extension found in the main bundle will be pinned. If you want more control over which certificates are pinned, please use `policyWithPinningMode:withPinnedCertificates:` instead.
|
||||
|
||||
@param pinningMode The SSL pinning mode.
|
||||
|
||||
@return A new security policy.
|
||||
|
||||
@see -policyWithPinningMode:withPinnedCertificates:
|
||||
*/
|
||||
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode;
|
||||
|
||||
@ -104,7 +108,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@param pinnedCertificates The certificates to pin against.
|
||||
|
||||
@return A new security policy.
|
||||
*/
|
||||
|
||||
@see +certificatesInBundle:
|
||||
@see -pinnedCertificates
|
||||
*/
|
||||
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet <NSData *> *)pinnedCertificates;
|
||||
|
||||
///------------------------------
|
||||
|
||||
@ -158,17 +158,6 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
||||
return [NSSet setWithSet:certificates];
|
||||
}
|
||||
|
||||
+ (NSSet *)defaultPinnedCertificates {
|
||||
static NSSet *_defaultPinnedCertificates = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
||||
_defaultPinnedCertificates = [self certificatesInBundle:bundle];
|
||||
});
|
||||
|
||||
return _defaultPinnedCertificates;
|
||||
}
|
||||
|
||||
+ (instancetype)defaultPolicy {
|
||||
AFSecurityPolicy *securityPolicy = [[self alloc] init];
|
||||
securityPolicy.SSLPinningMode = AFSSLPinningModeNone;
|
||||
@ -177,7 +166,8 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
||||
}
|
||||
|
||||
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode {
|
||||
return [self policyWithPinningMode:pinningMode withPinnedCertificates:[self defaultPinnedCertificates]];
|
||||
NSSet <NSData *> *defaultPinnedCertificates = [self certificatesInBundle:[NSBundle mainBundle]];
|
||||
return [self policyWithPinningMode:pinningMode withPinnedCertificates:defaultPinnedCertificates];
|
||||
}
|
||||
|
||||
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates {
|
||||
@ -252,9 +242,6 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
||||
}
|
||||
|
||||
switch (self.SSLPinningMode) {
|
||||
case AFSSLPinningModeNone:
|
||||
default:
|
||||
return NO;
|
||||
case AFSSLPinningModeCertificate: {
|
||||
NSMutableArray *pinnedCertificates = [NSMutableArray array];
|
||||
for (NSData *certificateData in self.pinnedCertificates) {
|
||||
@ -290,6 +277,9 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
||||
}
|
||||
return trustedPublicKeyCount > 0;
|
||||
}
|
||||
|
||||
default:
|
||||
return NO;
|
||||
}
|
||||
|
||||
return NO;
|
||||
@ -317,7 +307,7 @@ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
|
||||
self.SSLPinningMode = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(SSLPinningMode))] unsignedIntegerValue];
|
||||
self.allowInvalidCertificates = [decoder decodeBoolForKey:NSStringFromSelector(@selector(allowInvalidCertificates))];
|
||||
self.validatesDomainName = [decoder decodeBoolForKey:NSStringFromSelector(@selector(validatesDomainName))];
|
||||
self.pinnedCertificates = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(pinnedCertificates))];
|
||||
self.pinnedCertificates = [decoder decodeObjectOfClass:[NSSet class] forKey:NSStringFromSelector(@selector(pinnedCertificates))];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -217,12 +217,13 @@ static void *AFHTTPRequestSerializerObserverContext = &AFHTTPRequestSerializerOb
|
||||
}];
|
||||
[self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"];
|
||||
|
||||
// User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
|
||||
NSString *userAgent = nil;
|
||||
#if TARGET_OS_IOS
|
||||
// User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
|
||||
userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]];
|
||||
#elif TARGET_OS_TV
|
||||
userAgent = [NSString stringWithFormat:@"%@/%@ (%@; tvOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]];
|
||||
#elif TARGET_OS_WATCH
|
||||
// User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
|
||||
userAgent = [NSString stringWithFormat:@"%@/%@ (%@; watchOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[WKInterfaceDevice currentDevice] model], [[WKInterfaceDevice currentDevice] systemVersion], [[WKInterfaceDevice currentDevice] screenScale]];
|
||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||
userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]];
|
||||
@ -312,7 +313,7 @@ static void *AFHTTPRequestSerializerObserverContext = &AFHTTPRequestSerializerOb
|
||||
- (void)setValue:(NSString *)value
|
||||
forHTTPHeaderField:(NSString *)field
|
||||
{
|
||||
dispatch_barrier_async(self.requestHeaderModificationQueue, ^{
|
||||
dispatch_barrier_sync(self.requestHeaderModificationQueue, ^{
|
||||
[self.mutableHTTPRequestHeaders setValue:value forKey:field];
|
||||
});
|
||||
}
|
||||
@ -334,7 +335,7 @@ forHTTPHeaderField:(NSString *)field
|
||||
}
|
||||
|
||||
- (void)clearAuthorizationHeader {
|
||||
dispatch_barrier_async(self.requestHeaderModificationQueue, ^{
|
||||
dispatch_barrier_sync(self.requestHeaderModificationQueue, ^{
|
||||
[self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"];
|
||||
});
|
||||
}
|
||||
@ -571,7 +572,7 @@ forHTTPHeaderField:(NSString *)field
|
||||
dispatch_sync(self.requestHeaderModificationQueue, ^{
|
||||
[coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))];
|
||||
});
|
||||
[coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))];
|
||||
[coder encodeObject:@(self.queryStringSerializationStyle) forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))];
|
||||
}
|
||||
|
||||
#pragma mark - NSCopying
|
||||
@ -1295,7 +1296,7 @@ typedef enum {
|
||||
- (void)encodeWithCoder:(NSCoder *)coder {
|
||||
[super encodeWithCoder:coder];
|
||||
|
||||
[coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))];
|
||||
[coder encodeObject:@(self.writingOptions) forKey:NSStringFromSelector(@selector(writingOptions))];
|
||||
}
|
||||
|
||||
#pragma mark - NSCopying
|
||||
@ -1381,7 +1382,7 @@ typedef enum {
|
||||
- (void)encodeWithCoder:(NSCoder *)coder {
|
||||
[super encodeWithCoder:coder];
|
||||
|
||||
[coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))];
|
||||
[coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))];
|
||||
[coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))];
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,11 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Recursively removes `NSNull` values from a JSON object.
|
||||
*/
|
||||
id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions);
|
||||
|
||||
/**
|
||||
The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data.
|
||||
|
||||
|
||||
@ -60,11 +60,13 @@ static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger co
|
||||
return NO;
|
||||
}
|
||||
|
||||
static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) {
|
||||
id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) {
|
||||
if ([JSONObject isKindOfClass:[NSArray class]]) {
|
||||
NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]];
|
||||
for (id value in (NSArray *)JSONObject) {
|
||||
[mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)];
|
||||
if (![value isEqual:[NSNull null]]) {
|
||||
[mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)];
|
||||
}
|
||||
}
|
||||
|
||||
return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray];
|
||||
@ -112,7 +114,7 @@ static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingO
|
||||
BOOL responseIsValid = YES;
|
||||
NSError *validationError = nil;
|
||||
|
||||
if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||
if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]] &&
|
||||
!([response MIMEType] == nil && [data length] == 0)) {
|
||||
|
||||
@ -180,7 +182,7 @@ static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingO
|
||||
}
|
||||
|
||||
self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))];
|
||||
self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
|
||||
self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@
|
||||
### `NSURLSessionDownloadDelegate`
|
||||
|
||||
- `URLSession:downloadTask:didFinishDownloadingToURL:`
|
||||
- `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`
|
||||
- `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:`
|
||||
- `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`
|
||||
|
||||
If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first.
|
||||
@ -196,7 +196,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@param cancelPendingTasks Whether or not to cancel pending tasks.
|
||||
*/
|
||||
- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks;
|
||||
- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
Invalidates the managed session, optionally canceling pending tasks and optionally resets given session.
|
||||
|
||||
@param cancelPendingTasks Whether or not to cancel pending tasks.
|
||||
@param resetSession Whether or not to reset the session of the manager.
|
||||
*/
|
||||
- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks resetSession:(BOOL)resetSession;
|
||||
|
||||
///-------------------------
|
||||
/// @name Running Data Tasks
|
||||
@ -378,6 +386,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (void)setTaskDidCompleteBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSError * _Nullable error))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed when metrics are finalized related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didFinishCollectingMetrics:`.
|
||||
|
||||
@param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any metrics that were collected in the process of executing the task.
|
||||
*/
|
||||
#if AF_CAN_INCLUDE_SESSION_TASK_METRICS
|
||||
- (void)setTaskDidFinishCollectingMetricsBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSURLSessionTaskMetrics * _Nullable metrics))block;
|
||||
#endif
|
||||
///-------------------------------------------
|
||||
/// @name Setting Data Task Delegate Callbacks
|
||||
///-------------------------------------------
|
||||
@ -429,7 +445,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * _Nullable (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block;
|
||||
|
||||
/**
|
||||
Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`.
|
||||
Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:`.
|
||||
|
||||
@param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes five arguments: the session, the download task, the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the session manager operation queue.
|
||||
*/
|
||||
@ -498,4 +514,9 @@ FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteAssetPathKey;
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteErrorKey;
|
||||
|
||||
/**
|
||||
The session task metrics taken from the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteSessionTaskMetrics`
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSessionTaskMetrics;
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import "AFURLSessionManager.h"
|
||||
#import "AFCompatibilityMacros.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#ifndef NSFoundationVersionNumber_iOS_8_0
|
||||
@ -39,14 +38,16 @@ static dispatch_queue_t url_session_manager_creation_queue() {
|
||||
return af_url_session_manager_creation_queue;
|
||||
}
|
||||
|
||||
static void url_session_manager_create_task_safely(dispatch_block_t block) {
|
||||
if (NSFoundationVersionNumber < NSFoundationVersionNumber_With_Fixed_5871104061079552_bug) {
|
||||
// Fix of bug
|
||||
// Open Radar:http://openradar.appspot.com/radar?id=5871104061079552 (status: Fixed in iOS8)
|
||||
// Issue about:https://github.com/AFNetworking/AFNetworking/issues/2093
|
||||
dispatch_sync(url_session_manager_creation_queue(), block);
|
||||
} else {
|
||||
block();
|
||||
static void url_session_manager_create_task_safely(dispatch_block_t _Nonnull block) {
|
||||
if (block != NULL) {
|
||||
if (NSFoundationVersionNumber < NSFoundationVersionNumber_With_Fixed_5871104061079552_bug) {
|
||||
// Fix of bug
|
||||
// Open Radar:http://openradar.appspot.com/radar?id=5871104061079552 (status: Fixed in iOS8)
|
||||
// Issue about:https://github.com/AFNetworking/AFNetworking/issues/2093
|
||||
dispatch_sync(url_session_manager_creation_queue(), block);
|
||||
} else {
|
||||
block();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,6 +82,7 @@ NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamof
|
||||
NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata";
|
||||
NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error";
|
||||
NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath";
|
||||
NSString * const AFNetworkingTaskDidCompleteSessionTaskMetrics = @"com.alamofire.networking.complete.sessiontaskmetrics";
|
||||
|
||||
static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock";
|
||||
|
||||
@ -96,6 +98,9 @@ typedef void (^AFURLSessionDidFinishEventsForBackgroundURLSessionBlock)(NSURLSes
|
||||
typedef NSInputStream * (^AFURLSessionTaskNeedNewBodyStreamBlock)(NSURLSession *session, NSURLSessionTask *task);
|
||||
typedef void (^AFURLSessionTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend);
|
||||
typedef void (^AFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error);
|
||||
#if AF_CAN_INCLUDE_SESSION_TASK_METRICS
|
||||
typedef void (^AFURLSessionTaskDidFinishCollectingMetricsBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLSessionTaskMetrics * metrics);
|
||||
#endif
|
||||
|
||||
typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response);
|
||||
typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask);
|
||||
@ -119,6 +124,9 @@ typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id re
|
||||
@property (nonatomic, strong) NSProgress *uploadProgress;
|
||||
@property (nonatomic, strong) NSProgress *downloadProgress;
|
||||
@property (nonatomic, copy) NSURL *downloadFileURL;
|
||||
#if AF_CAN_INCLUDE_SESSION_TASK_METRICS
|
||||
@property (nonatomic, strong) NSURLSessionTaskMetrics *sessionTaskMetrics;
|
||||
#endif
|
||||
@property (nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading;
|
||||
@property (nonatomic, copy) AFURLSessionTaskProgressBlock uploadProgressBlock;
|
||||
@property (nonatomic, copy) AFURLSessionTaskProgressBlock downloadProgressBlock;
|
||||
@ -209,6 +217,14 @@ didCompleteWithError:(NSError *)error
|
||||
self.mutableData = nil;
|
||||
}
|
||||
|
||||
#if AF_CAN_USE_AT_AVAILABLE && AF_CAN_INCLUDE_SESSION_TASK_METRICS
|
||||
if (@available(iOS 10, macOS 10.12, watchOS 3, tvOS 10, *)) {
|
||||
if (self.sessionTaskMetrics) {
|
||||
userInfo[AFNetworkingTaskDidCompleteSessionTaskMetrics] = self.sessionTaskMetrics;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (self.downloadFileURL) {
|
||||
userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL;
|
||||
} else if (data) {
|
||||
@ -257,6 +273,14 @@ didCompleteWithError:(NSError *)error
|
||||
}
|
||||
}
|
||||
|
||||
#if AF_CAN_INCLUDE_SESSION_TASK_METRICS
|
||||
- (void)URLSession:(NSURLSession *)session
|
||||
task:(NSURLSessionTask *)task
|
||||
didFinishCollectingMetrics:(NSURLSessionTaskMetrics *)metrics {
|
||||
self.sessionTaskMetrics = metrics;
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma mark - NSURLSessionDataDelegate
|
||||
|
||||
- (void)URLSession:(__unused NSURLSession *)session
|
||||
@ -381,7 +405,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
||||
8) Set the current class to the super class, and repeat steps 3-8
|
||||
*/
|
||||
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration];
|
||||
NSURLSession * session = [NSURLSession sessionWithConfiguration:configuration];
|
||||
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnonnull"
|
||||
NSURLSessionDataTask *localDataTask = [session dataTaskWithURL:nil];
|
||||
@ -461,6 +485,9 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream;
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionTaskDidSendBodyDataBlock taskDidSendBodyData;
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionTaskDidCompleteBlock taskDidComplete;
|
||||
#if AF_CAN_INCLUDE_SESSION_TASK_METRICS
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionTaskDidFinishCollectingMetricsBlock taskDidFinishCollectingMetrics;
|
||||
#endif
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveResponseBlock dataTaskDidReceiveResponse;
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidBecomeDownloadTaskBlock dataTaskDidBecomeDownloadTask;
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveDataBlock dataTaskDidReceiveData;
|
||||
@ -491,8 +518,6 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
||||
self.operationQueue = [[NSOperationQueue alloc] init];
|
||||
self.operationQueue.maxConcurrentOperationCount = 1;
|
||||
|
||||
self.session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue];
|
||||
|
||||
self.responseSerializer = [AFJSONResponseSerializer serializer];
|
||||
|
||||
self.securityPolicy = [AFSecurityPolicy defaultPolicy];
|
||||
@ -529,6 +554,19 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (NSURLSession *)session {
|
||||
|
||||
@synchronized (self) {
|
||||
if (!_session) {
|
||||
_session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue];
|
||||
}
|
||||
}
|
||||
return _session;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
- (NSString *)taskDescriptionForSessionTasks {
|
||||
return [NSString stringWithFormat:@"%p", self];
|
||||
}
|
||||
@ -685,11 +723,18 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
||||
#pragma mark -
|
||||
|
||||
- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks {
|
||||
[self invalidateSessionCancelingTasks:cancelPendingTasks resetSession:NO];
|
||||
}
|
||||
|
||||
- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks resetSession:(BOOL)resetSession {
|
||||
if (cancelPendingTasks) {
|
||||
[self.session invalidateAndCancel];
|
||||
} else {
|
||||
[self.session finishTasksAndInvalidate];
|
||||
}
|
||||
if (resetSession) {
|
||||
self.session = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
@ -870,6 +915,12 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
||||
self.taskDidComplete = block;
|
||||
}
|
||||
|
||||
#if AF_CAN_INCLUDE_SESSION_TASK_METRICS
|
||||
- (void)setTaskDidFinishCollectingMetricsBlock:(void (^)(NSURLSession * _Nonnull, NSURLSessionTask * _Nonnull, NSURLSessionTaskMetrics * _Nullable))block {
|
||||
self.taskDidFinishCollectingMetrics = block;
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block {
|
||||
@ -1040,9 +1091,9 @@ totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend
|
||||
{
|
||||
|
||||
int64_t totalUnitCount = totalBytesExpectedToSend;
|
||||
if(totalUnitCount == NSURLSessionTransferSizeUnknown) {
|
||||
if (totalUnitCount == NSURLSessionTransferSizeUnknown) {
|
||||
NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"];
|
||||
if(contentLength) {
|
||||
if (contentLength) {
|
||||
totalUnitCount = (int64_t) [contentLength longLongValue];
|
||||
}
|
||||
}
|
||||
@ -1076,6 +1127,23 @@ didCompleteWithError:(NSError *)error
|
||||
}
|
||||
}
|
||||
|
||||
#if AF_CAN_INCLUDE_SESSION_TASK_METRICS
|
||||
- (void)URLSession:(NSURLSession *)session
|
||||
task:(NSURLSessionTask *)task
|
||||
didFinishCollectingMetrics:(NSURLSessionTaskMetrics *)metrics
|
||||
{
|
||||
AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task];
|
||||
// Metrics may fire after URLSession:task:didCompleteWithError: is called, delegate may be nil
|
||||
if (delegate) {
|
||||
[delegate URLSession:session task:task didFinishCollectingMetrics:metrics];
|
||||
}
|
||||
|
||||
if (self.taskDidFinishCollectingMetrics) {
|
||||
self.taskDidFinishCollectingMetrics(session, task, metrics);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma mark - NSURLSessionDataDelegate
|
||||
|
||||
- (void)URLSession:(NSURLSession *)session
|
||||
|
||||
22
CHANGELOG.md
22
CHANGELOG.md
@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
---
|
||||
|
||||
## [3.2.1](https://github.com/AFNetworking/AFNetworking/releases/tag/3.2.1) (05/04/2018)
|
||||
Released on Friday, May 04, 2018. All issues associated with this milestone can be found using this [filter](https://github.com/AFNetworking/AFNetworking/issues?q=milestone%3A3.2.1+is%3Aclosed).
|
||||
|
||||
#### Updated
|
||||
* Xcode 9.3 Support
|
||||
* Implemented by Jeff Kelley in [#4199](https://github.com/AFNetworking/AFNetworking/pull/4199).
|
||||
* Update HTTPBin certificates for April 2018.
|
||||
* Implemented by Jeff Kelley in [#4198](https://github.com/AFNetworking/AFNetworking/pull/4198).
|
||||
|
||||
#### Additional Changes
|
||||
* Remove conflicting nullable specifier on init
|
||||
* Implemented by Nick Brook and Jeff Kelley in [#4182](https://github.com/AFNetworking/AFNetworking/pull/4182).
|
||||
* Use @available if available to silence a warning.
|
||||
* Implemented by Jeff Kelley in [#4138](https://github.com/AFNetworking/AFNetworking/pull/4138).
|
||||
* UIImageView+AFNetworking: Prevent stuck state for malformed urlRequest
|
||||
* Implemented by Adam Duflo and aduflo in [#4131](https://github.com/AFNetworking/AFNetworking/pull/4131).
|
||||
* add the link for LICENSE
|
||||
* Implemented by Liao Malin in [#4125](https://github.com/AFNetworking/AFNetworking/pull/4125).
|
||||
* Fix analyzer warning for upload task creation
|
||||
* Implemented by Jeff Kelley in [#4122](https://github.com/AFNetworking/AFNetworking/pull/4122).
|
||||
|
||||
|
||||
## [3.2.0](https://github.com/AFNetworking/AFNetworking/releases/tag/3.2.0) (12/15/2017)
|
||||
Released on Friday, December 15, 2017. All issues associated with this milestone can be found using this [filter](https://github.com/AFNetworking/AFNetworking/issues?q=milestone%3A3.2.0+is%3Aclosed).
|
||||
|
||||
|
||||
97
CONTRIBUTING_CH.md
Normal file
97
CONTRIBUTING_CH.md
Normal file
@ -0,0 +1,97 @@
|
||||
# 贡献指南
|
||||
本文档包含有关为此项目做出贡献的信息和指南。
|
||||
请在开始参加之前阅读。
|
||||
|
||||
**主题**
|
||||
|
||||
* [提问](#提问)
|
||||
* [报告安全问题](#报告安全问题)
|
||||
* [报告其他问题](#报告其他问题)
|
||||
* [提交拉取请求](#提交拉取请求)
|
||||
* [开发人员原产地证书](#开发人员原产地证书-1.1)
|
||||
* [行为守则](#行为守则)
|
||||
|
||||
## 提问
|
||||
|
||||
我们不使用GitHub的论坛发表问题
|
||||
对于任何非特定于项目本身的使用问题,
|
||||
请直接在[Stack Overflow](https://stackoverflow.com)上询问。
|
||||
通过此方法,你可以快速解决您的问题,
|
||||
并且任何有相同问题的人可以找到答案。
|
||||
这也使维护人员能够专注于为其他人改进项目。
|
||||
|
||||
## 报告安全问题
|
||||
|
||||
Alamofire Software Foundation 认真对待安全问题。
|
||||
如果您发现任何关于安全的问题,请立即通知我们!
|
||||
|
||||
请**不要**公然公开发布问题,
|
||||
而是将您的问题私下发送到<security@alamofire.org>。
|
||||
这将有于帮助确保发现的任何漏洞
|
||||
可以[披露制度](http://en.wikipedia.org/wiki/Responsible_disclosure)
|
||||
对任何受影响的各方
|
||||
|
||||
## 报告其他问题
|
||||
|
||||
为此项目贡献的方法
|
||||
是当遇到问题时,请发送一篇详细的错误报告。
|
||||
我们会感谢您写出的一份精心编写的详尽错误报告。
|
||||
|
||||
在提交问题之前,请检查项目里的问题数据库是否已存在此问题。
|
||||
如果您找到匹配项,请添加“+1”或“我也遇到此问题”。
|
||||
这样做有助于确定最常见问题和请求的优先级。
|
||||
|
||||
报告问题时,请包含以下内容:
|
||||
|
||||
* 您正在使用的Xcode版本
|
||||
* 您的iOS或OS X版本
|
||||
* 任何堆栈轨迹或编译器错误的完整输出
|
||||
* 如果代码段可再现所描述的行为
|
||||
* 任何其他有助于理解问题的细节
|
||||
|
||||
此信息有助于我们更快地查看和修复您的问题。
|
||||
|
||||
## 提交拉取请求
|
||||
|
||||
大力鼓励和欢迎拉取请求。在提交拉取请求时,请创建适当的测试用例,说明修复的问题或新功能。
|
||||
|
||||
## 开发人员原产地证书 1.1
|
||||
|
||||
为了项目做出贡献,我保证:
|
||||
|
||||
- (a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
- (b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
- (c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
- (d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
|
||||
## 行为守则
|
||||
|
||||
该项目采取贡献者公约为准则。
|
||||
|
||||
这项目的成果将会被我们的行为或行动影响。
|
||||
|
||||
我们期望每个为此项目做出贡献的人都会对此表示敬意。
|
||||
|
||||
详情请阅读 [CONDUCT.md](https://github.com/Alamofire/Foundation/blob/master/CONDUCT.md)。
|
||||
|
||||
----
|
||||
|
||||
*上述陈述的一些想法和措辞是基于 [Docker](https://github.com/docker/docker/blob/master/CONTRIBUTING.md) 和 [Linux](http://elinux.org/Developer_Certificate_Of_Origin) 社区.
|
||||
我们表彰和感激他们为促进项目合作所做的付出。*
|
||||
@ -528,6 +528,7 @@
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
@ -1027,7 +1028,7 @@
|
||||
SDKROOT = appletvos;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/tvOS Example/AFNetworking tvOS Example-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
};
|
||||
@ -1072,7 +1073,7 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = appletvos;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/tvOS Example/AFNetworking tvOS Example-Bridging-Header.h";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
|
||||
@ -237,6 +237,7 @@
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
@ -390,6 +391,7 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/tvOS Example/AFNetworking tvOS Example-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -405,6 +407,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.AFNetworking-tvOS-Example";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/tvOS Example/AFNetworking tvOS Example-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
@ -50,7 +50,6 @@
|
||||
- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
|
||||
[Post globalTimelinePostsWithBlock:^(NSArray *posts, NSError *error) {
|
||||
if (!error) {
|
||||
|
||||
self.post = posts.firstObject;
|
||||
[self savePost:self.post];
|
||||
|
||||
|
||||
@ -46,8 +46,10 @@
|
||||
self.postsArrayController.content = posts;
|
||||
}];
|
||||
|
||||
__weak __typeof(self)weakSelf = self;
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:kUserProfileImageDidLoadNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
|
||||
[self.tableView reloadData];
|
||||
__strong __typeof(weakSelf)strongSelf = weakSelf;
|
||||
[strongSelf.tableView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ private extension String {
|
||||
hash += String(format: "%02x", result[i])
|
||||
}
|
||||
|
||||
result.deallocate(capacity: digestLength)
|
||||
result.deallocate()
|
||||
|
||||
return String(format: hash)
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>3.2.0</string>
|
||||
<string>3.2.1</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
[](http://cocoadocs.org/docsets/AFNetworking)
|
||||
[](http://twitter.com/AFNetworking)
|
||||
|
||||
AFNetworking is a delightful networking library for iOS, macOS, watchOS, and tvOS. It's built on top of the [Foundation URL Loading System](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use.
|
||||
AFNetworking is a delightful networking library for iOS, macOS, watchOS, and tvOS. It's built on top of the [Foundation URL Loading System](https://developer.apple.com/documentation/foundation/url_loading_system), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use.
|
||||
|
||||
Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac.
|
||||
|
||||
|
||||
BIN
Tests/Resources/HTTPBin.org/Amazon Root CA 1.cer
Normal file
BIN
Tests/Resources/HTTPBin.org/Amazon Root CA 1.cer
Normal file
Binary file not shown.
BIN
Tests/Resources/HTTPBin.org/Amazon.cer
Normal file
BIN
Tests/Resources/HTTPBin.org/Amazon.cer
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Tests/Resources/HTTPBin.org/httpbinorg_03172020.cer
Normal file
BIN
Tests/Resources/HTTPBin.org/httpbinorg_03172020.cer
Normal file
Binary file not shown.
Binary file not shown.
@ -219,7 +219,7 @@
|
||||
UInt64 postPurgeMemoryUsage = self.cache.memoryUsage;
|
||||
XCTAssertTrue(postPurgeMemoryUsage < prePurgeMemoryUsage);
|
||||
|
||||
for (NSUInteger index = 0; index <= numberOfImages ; index++) {
|
||||
for (NSUInteger index = 0; index <= numberOfImages; index++) {
|
||||
NSString * identifier = [NSString stringWithFormat:@"image-%ld",(long)index];
|
||||
UIImage *cachedImage = [self.cache imageWithIdentifier:identifier];
|
||||
if (index == 0 || index >= 6) {
|
||||
|
||||
@ -71,8 +71,8 @@
|
||||
XCTAssertNotNil(copiedSerializer);
|
||||
XCTAssertNotEqual(compoundSerializer, copiedSerializer);
|
||||
XCTAssertTrue(compoundSerializer.responseSerializers.count == copiedSerializer.responseSerializers.count);
|
||||
XCTAssertTrue([NSStringFromClass([[copiedSerializer.responseSerializers objectAtIndex:0] class]) isEqualToString:NSStringFromClass([AFImageResponseSerializer class])]);
|
||||
XCTAssertTrue([NSStringFromClass([[copiedSerializer.responseSerializers objectAtIndex:1] class]) isEqualToString:NSStringFromClass([AFJSONResponseSerializer class])]);
|
||||
XCTAssertTrue([NSStringFromClass([copiedSerializer.responseSerializers[0] class]) isEqualToString:NSStringFromClass([AFImageResponseSerializer class])]);
|
||||
XCTAssertTrue([NSStringFromClass([copiedSerializer.responseSerializers[1] class]) isEqualToString:NSStringFromClass([AFJSONResponseSerializer class])]);
|
||||
XCTAssertEqual(compoundSerializer.acceptableStatusCodes, copiedSerializer.acceptableStatusCodes);
|
||||
XCTAssertEqual(compoundSerializer.acceptableContentTypes, copiedSerializer.acceptableContentTypes);
|
||||
}
|
||||
@ -87,8 +87,8 @@
|
||||
XCTAssertNotNil(unarchivedSerializer);
|
||||
XCTAssertNotEqual(unarchivedSerializer, compoundSerializer);
|
||||
XCTAssertTrue(compoundSerializer.responseSerializers.count == compoundSerializer.responseSerializers.count);
|
||||
XCTAssertTrue([NSStringFromClass([[unarchivedSerializer.responseSerializers objectAtIndex:0] class]) isEqualToString:NSStringFromClass([AFImageResponseSerializer class])]);
|
||||
XCTAssertTrue([NSStringFromClass([[unarchivedSerializer.responseSerializers objectAtIndex:1] class]) isEqualToString:NSStringFromClass([AFJSONResponseSerializer class])]);
|
||||
XCTAssertTrue([NSStringFromClass([unarchivedSerializer.responseSerializers[0] class]) isEqualToString:NSStringFromClass([AFImageResponseSerializer class])]);
|
||||
XCTAssertTrue([NSStringFromClass([unarchivedSerializer.responseSerializers[1] class]) isEqualToString:NSStringFromClass([AFJSONResponseSerializer class])]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -25,24 +25,25 @@
|
||||
#import "AFSecurityPolicy.h"
|
||||
|
||||
@interface AFHTTPSessionManagerTests : AFTestCase
|
||||
@property (readwrite, nonatomic, strong) AFHTTPSessionManager *manager;
|
||||
@property (readwrite, nonatomic, strong) AFHTTPSessionManager *sessionManager;
|
||||
@end
|
||||
|
||||
@implementation AFHTTPSessionManagerTests
|
||||
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
self.manager = [[AFHTTPSessionManager alloc] initWithBaseURL:self.baseURL];
|
||||
self.sessionManager = [[AFHTTPSessionManager alloc] initWithBaseURL:self.baseURL];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
[self.manager invalidateSessionCancelingTasks:YES];
|
||||
[self.sessionManager invalidateSessionCancelingTasks:YES resetSession:NO];
|
||||
self.sessionManager = nil;
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
#pragma mark - init
|
||||
- (void)testSharedManagerIsNotEqualToInitdManager {
|
||||
XCTAssertFalse([[AFHTTPSessionManager manager] isEqual:self.manager]);
|
||||
- (void)testSharedManagerIsNotEqualToInitedManager {
|
||||
XCTAssertFalse([[AFHTTPSessionManager manager] isEqual:self.sessionManager]);
|
||||
}
|
||||
|
||||
#pragma mark - misc
|
||||
@ -54,7 +55,7 @@
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/get" relativeToURL:self.baseURL]];
|
||||
NSURLSessionDataTask *task = [self.manager dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil
|
||||
NSURLSessionDataTask *task = [self.sessionManager dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil
|
||||
completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
blockResponseObject = responseObject;
|
||||
blockError = error;
|
||||
@ -76,7 +77,7 @@
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/status/404" relativeToURL:self.baseURL]];
|
||||
NSURLSessionDataTask *task = [self.manager dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil
|
||||
NSURLSessionDataTask *task = [self.sessionManager dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil
|
||||
completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
blockError = error;
|
||||
[expectation fulfill];
|
||||
@ -97,13 +98,13 @@
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
|
||||
NSURLRequest *redirectRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/redirect/1" relativeToURL:self.baseURL]];
|
||||
NSURLSessionDataTask *redirectTask = [self.manager dataTaskWithRequest:redirectRequest uploadProgress:nil downloadProgress:nil
|
||||
NSURLSessionDataTask *redirectTask = [self.sessionManager dataTaskWithRequest:redirectRequest uploadProgress:nil downloadProgress:nil
|
||||
completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
blockError = error;
|
||||
[expectation fulfill];
|
||||
}];
|
||||
|
||||
[self.manager setTaskWillPerformHTTPRedirectionBlock:^NSURLRequest *(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request) {
|
||||
[self.sessionManager setTaskWillPerformHTTPRedirectionBlock:^NSURLRequest *(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request) {
|
||||
if (response) {
|
||||
success = YES;
|
||||
}
|
||||
@ -126,14 +127,14 @@
|
||||
__block NSURL *downloadFilePath = nil;
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
|
||||
[self.manager setDownloadTaskDidFinishDownloadingBlock:^NSURL *(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location) {
|
||||
[self.sessionManager setDownloadTaskDidFinishDownloadingBlock:^NSURL *(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location) {
|
||||
managerDownloadFinishedBlockExecuted = YES;
|
||||
NSURL *dirURL = [[[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject];
|
||||
return [dirURL URLByAppendingPathComponent:@"t1.file"];
|
||||
}];
|
||||
|
||||
NSURLSessionDownloadTask *downloadTask;
|
||||
downloadTask = [self.manager
|
||||
downloadTask = [self.sessionManager
|
||||
downloadTaskWithRequest:[NSURLRequest requestWithURL:self.baseURL]
|
||||
progress:nil
|
||||
destination:nil
|
||||
@ -155,7 +156,7 @@
|
||||
__block NSURL *downloadFilePath = nil;
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
|
||||
NSURLSessionDownloadTask *downloadTask = [self.manager downloadTaskWithRequest:[NSURLRequest requestWithURL:self.baseURL]
|
||||
NSURLSessionDownloadTask *downloadTask = [self.sessionManager downloadTaskWithRequest:[NSURLRequest requestWithURL:self.baseURL]
|
||||
progress:nil
|
||||
destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
|
||||
destinationBlockExecuted = YES;
|
||||
@ -177,7 +178,7 @@
|
||||
- (void)testThatSerializationErrorGeneratesErrorAndNullTaskForGET {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Serialization should fail"];
|
||||
|
||||
[self.manager.requestSerializer setQueryStringSerializationWithBlock:^NSString * _Nonnull(NSURLRequest * _Nonnull request, id _Nonnull parameters, NSError * _Nullable __autoreleasing * _Nullable error) {
|
||||
[self.sessionManager.requestSerializer setQueryStringSerializationWithBlock:^NSString * _Nonnull(NSURLRequest * _Nonnull request, id _Nonnull parameters, NSError * _Nullable __autoreleasing * _Nullable error) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:@"Custom" code:-1 userInfo:nil];
|
||||
}
|
||||
@ -185,9 +186,10 @@
|
||||
}];
|
||||
|
||||
NSURLSessionTask *nilTask;
|
||||
nilTask = [self.manager
|
||||
nilTask = [self.sessionManager
|
||||
GET:@"test"
|
||||
parameters:@{@"key":@"value"}
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:nil
|
||||
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
@ -205,12 +207,12 @@
|
||||
}
|
||||
|
||||
- (void)testCanBeEncoded {
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self.manager];
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self.sessionManager];
|
||||
XCTAssertNotNil(data);
|
||||
}
|
||||
|
||||
- (void)testCanBeDecoded {
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self.manager];
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self.sessionManager];
|
||||
AFHTTPSessionManager *newManager = [NSKeyedUnarchiver unarchiveObjectWithData:data];
|
||||
XCTAssertNotNil(newManager.securityPolicy);
|
||||
XCTAssertNotNil(newManager.requestSerializer);
|
||||
@ -223,7 +225,7 @@
|
||||
#pragma mark - NSCopying
|
||||
|
||||
- (void)testCanBeCopied {
|
||||
AFHTTPSessionManager *copyManager = [self.manager copy];
|
||||
AFHTTPSessionManager *copyManager = [self.sessionManager copy];
|
||||
XCTAssertNotNil(copyManager);
|
||||
}
|
||||
|
||||
@ -231,9 +233,10 @@
|
||||
|
||||
- (void)testDownloadProgressIsReportedForGET {
|
||||
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Progress Should equal 1.0"];
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
GET:@"image"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:^(NSProgress * _Nonnull downloadProgress) {
|
||||
if (downloadProgress.fractionCompleted == 1.0) {
|
||||
[expectation fulfill];
|
||||
@ -252,9 +255,10 @@
|
||||
|
||||
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Progress Should equal 1.0"];
|
||||
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
POST:@"post"
|
||||
parameters:payload
|
||||
headers:nil
|
||||
progress:^(NSProgress * _Nonnull uploadProgress) {
|
||||
if (uploadProgress.fractionCompleted == 1.0) {
|
||||
[expectation fulfill];
|
||||
@ -273,9 +277,10 @@
|
||||
|
||||
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Progress Should equal 1.0"];
|
||||
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
POST:@"post"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
|
||||
[formData appendPartWithFileData:[payload dataUsingEncoding:NSUTF8StringEncoding] name:@"AFNetworking" fileName:@"AFNetworking" mimeType:@"text/html"];
|
||||
}
|
||||
@ -289,13 +294,83 @@
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
# pragma mark - Deprecated Progress
|
||||
|
||||
- (void)testDownloadProgressIsReportedForDeprecatedGET {
|
||||
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Progress Should equal 1.0"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.sessionManager
|
||||
GET:@"image"
|
||||
parameters:nil
|
||||
progress:^(NSProgress * _Nonnull downloadProgress) {
|
||||
if (downloadProgress.fractionCompleted == 1.0) {
|
||||
[expectation fulfill];
|
||||
}
|
||||
}
|
||||
success:nil
|
||||
failure:nil];
|
||||
#pragma clang diagnostic pop
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testUploadProgressIsReportedForDeprecatedPOST {
|
||||
NSMutableString *payload = [NSMutableString stringWithString:@"AFNetworking"];
|
||||
while ([payload lengthOfBytesUsingEncoding:NSUTF8StringEncoding] < 20000) {
|
||||
[payload appendString:@"AFNetworking"];
|
||||
}
|
||||
|
||||
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Progress Should equal 1.0"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.sessionManager
|
||||
POST:@"post"
|
||||
parameters:payload
|
||||
progress:^(NSProgress * _Nonnull uploadProgress) {
|
||||
if (uploadProgress.fractionCompleted == 1.0) {
|
||||
[expectation fulfill];
|
||||
}
|
||||
}
|
||||
success:nil
|
||||
failure:nil];
|
||||
#pragma clang diagnostic pop
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testUploadProgressIsReportedForStreamingDeprecatedPost {
|
||||
NSMutableString *payload = [NSMutableString stringWithString:@"AFNetworking"];
|
||||
while ([payload lengthOfBytesUsingEncoding:NSUTF8StringEncoding] < 20000) {
|
||||
[payload appendString:@"AFNetworking"];
|
||||
}
|
||||
|
||||
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Progress Should equal 1.0"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.sessionManager
|
||||
POST:@"post"
|
||||
parameters:nil
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
|
||||
[formData appendPartWithFileData:[payload dataUsingEncoding:NSUTF8StringEncoding] name:@"AFNetworking" fileName:@"AFNetworking" mimeType:@"text/html"];
|
||||
}
|
||||
progress:^(NSProgress * _Nonnull uploadProgress) {
|
||||
if (uploadProgress.fractionCompleted == 1.0) {
|
||||
[expectation fulfill];
|
||||
}
|
||||
}
|
||||
success:nil
|
||||
failure:nil];
|
||||
#pragma clang diagnostic pop
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
# pragma mark - HTTP Status Codes
|
||||
|
||||
- (void)testThatSuccessBlockIsCalledFor200 {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
GET:@"status/200"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
[expectation fulfill];
|
||||
@ -306,9 +381,10 @@
|
||||
|
||||
- (void)testThatFailureBlockIsCalledFor404 {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
GET:@"status/404"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:nil
|
||||
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nullable error) {
|
||||
@ -320,9 +396,10 @@
|
||||
- (void)testThatResponseObjectIsEmptyFor204 {
|
||||
__block id urlResponseObject = nil;
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
GET:@"status/204"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
urlResponseObject = responseObject;
|
||||
@ -337,9 +414,10 @@
|
||||
|
||||
- (void)testGET {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
GET:@"get"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertNotNil(responseObject);
|
||||
@ -351,9 +429,10 @@
|
||||
|
||||
- (void)testHEAD {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
HEAD:@"get"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task) {
|
||||
XCTAssertNotNil(task);
|
||||
[expectation fulfill];
|
||||
@ -364,11 +443,13 @@
|
||||
|
||||
- (void)testPOST {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
POST:@"post"
|
||||
parameters:@{@"key":@"value"}
|
||||
headers:@{@"field":@"value"}
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertTrue([task.originalRequest.allHTTPHeaderFields[@"field"] isEqualToString:@"value"]);
|
||||
XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]);
|
||||
[expectation fulfill];
|
||||
}
|
||||
@ -378,9 +459,10 @@
|
||||
|
||||
- (void)testPOSTWithConstructingBody {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
POST:@"post"
|
||||
parameters:@{@"key":@"value"}
|
||||
headers:@{@"field":@"value"}
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
|
||||
[formData appendPartWithFileData:[@"Data" dataUsingEncoding:NSUTF8StringEncoding]
|
||||
name:@"DataName"
|
||||
@ -389,6 +471,7 @@
|
||||
}
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertTrue([task.originalRequest.allHTTPHeaderFields[@"field"] isEqualToString:@"value"]);
|
||||
XCTAssertTrue([responseObject[@"files"][@"DataName"] isEqualToString:@"Data"]);
|
||||
XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]);
|
||||
[expectation fulfill];
|
||||
@ -399,10 +482,12 @@
|
||||
|
||||
- (void)testPUT {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
PUT:@"put"
|
||||
parameters:@{@"key":@"value"}
|
||||
headers:@{@"field":@"value"}
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertTrue([task.originalRequest.allHTTPHeaderFields[@"field"] isEqualToString:@"value"]);
|
||||
XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]);
|
||||
[expectation fulfill];
|
||||
}
|
||||
@ -412,10 +497,12 @@
|
||||
|
||||
- (void)testDELETE {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
DELETE:@"delete"
|
||||
parameters:@{@"key":@"value"}
|
||||
headers:@{@"field":@"value"}
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertTrue([task.originalRequest.allHTTPHeaderFields[@"field"] isEqualToString:@"value"]);
|
||||
XCTAssertTrue([responseObject[@"args"][@"key"] isEqualToString:@"value"]);
|
||||
[expectation fulfill];
|
||||
}
|
||||
@ -425,10 +512,12 @@
|
||||
|
||||
- (void)testPATCH {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
PATCH:@"patch"
|
||||
parameters:@{@"key":@"value"}
|
||||
headers:@{@"field":@"value"}
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertTrue([task.originalRequest.allHTTPHeaderFields[@"field"] isEqualToString:@"value"]);
|
||||
XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]);
|
||||
[expectation fulfill];
|
||||
}
|
||||
@ -439,11 +528,11 @@
|
||||
|
||||
#pragma mark - Deprecated Rest Interface
|
||||
|
||||
- (void)testDeprecatedGET {
|
||||
- (void)testDeprecatedGETWithoutProgress {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
GET:@"get"
|
||||
parameters:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
@ -455,11 +544,11 @@
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testDeprecatedPOST {
|
||||
- (void)testDeprecatedPOSTWithoutProgress {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
POST:@"post"
|
||||
parameters:@{@"key":@"value"}
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
@ -471,11 +560,11 @@
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testDeprecatedPOSTWithConstructingBody {
|
||||
- (void)testDeprecatedPOSTWithoutProgressWithConstructingBody {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.manager
|
||||
[self.sessionManager
|
||||
POST:@"post"
|
||||
parameters:@{@"key":@"value"}
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
|
||||
@ -494,14 +583,138 @@
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
|
||||
- (void)testDeprecatedGETWithoutHeaders {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.sessionManager
|
||||
GET:@"get"
|
||||
parameters:nil
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertNotNil(responseObject);
|
||||
[expectation fulfill];
|
||||
}
|
||||
failure:nil];
|
||||
#pragma clang diagnostic pop
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testDeprecatedHEADWithoutHeaders {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.sessionManager
|
||||
HEAD:@"get"
|
||||
parameters:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task) {
|
||||
XCTAssertNotNil(task);
|
||||
[expectation fulfill];
|
||||
}
|
||||
failure:nil];
|
||||
#pragma clang diagnostic pop
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testDeprecatedPOSTWithoutHeaders {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.sessionManager
|
||||
POST:@"post"
|
||||
parameters:@{@"key":@"value"}
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]);
|
||||
[expectation fulfill];
|
||||
}
|
||||
failure:nil];
|
||||
#pragma clang diagnostic pop
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testDeprecatedPOSTWithoutHeadersWithConstructingBody {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.sessionManager
|
||||
POST:@"post"
|
||||
parameters:@{@"key":@"value"}
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
|
||||
[formData appendPartWithFileData:[@"Data" dataUsingEncoding:NSUTF8StringEncoding]
|
||||
name:@"DataName"
|
||||
fileName:@"DataFileName"
|
||||
mimeType:@"data"];
|
||||
}
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertTrue([responseObject[@"files"][@"DataName"] isEqualToString:@"Data"]);
|
||||
XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]);
|
||||
[expectation fulfill];
|
||||
}
|
||||
failure:nil];
|
||||
#pragma clang diagnostic pop
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testDeprecatedPUTWithoutHeaders {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.sessionManager
|
||||
PUT:@"put"
|
||||
parameters:@{@"key":@"value"}
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]);
|
||||
[expectation fulfill];
|
||||
}
|
||||
failure:nil];
|
||||
#pragma clang diagnostic pop
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testDeprecatedDELETEWithoutHeaders {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.sessionManager
|
||||
DELETE:@"delete"
|
||||
parameters:@{@"key":@"value"}
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertTrue([responseObject[@"args"][@"key"] isEqualToString:@"value"]);
|
||||
[expectation fulfill];
|
||||
}
|
||||
failure:nil];
|
||||
#pragma clang diagnostic pop
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testDeprecatedPATCHWithoutHeaders {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self.sessionManager
|
||||
PATCH:@"patch"
|
||||
parameters:@{@"key":@"value"}
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]);
|
||||
[expectation fulfill];
|
||||
}
|
||||
failure:nil];
|
||||
#pragma clang diagnostic pop
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
#pragma mark - Auth
|
||||
|
||||
- (void)testHiddenBasicAuthentication {
|
||||
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Request should finish"];
|
||||
[self.manager.requestSerializer setAuthorizationHeaderFieldWithUsername:@"user" password:@"password"];
|
||||
[self.manager
|
||||
[self.sessionManager.requestSerializer setAuthorizationHeaderFieldWithUsername:@"user" password:@"password"];
|
||||
[self.sessionManager
|
||||
GET:@"hidden-basic-auth/user/password"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
[expectation fulfill];
|
||||
@ -574,6 +787,7 @@
|
||||
[manager
|
||||
GET:@""
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTFail(@"Request should fail");
|
||||
@ -585,7 +799,7 @@
|
||||
[expectation fulfill];
|
||||
}];
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
[manager invalidateSessionCancelingTasks:YES];
|
||||
[manager invalidateSessionCancelingTasks:YES resetSession:NO];
|
||||
}
|
||||
|
||||
- (void)testInvalidServerTrustProducesCorrectErrorForPublicKeyPinning {
|
||||
@ -598,6 +812,7 @@
|
||||
[manager
|
||||
GET:@""
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
XCTFail(@"Request should fail");
|
||||
@ -609,7 +824,7 @@
|
||||
[expectation fulfill];
|
||||
}];
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
[manager invalidateSessionCancelingTasks:YES];
|
||||
[manager invalidateSessionCancelingTasks:YES resetSession:NO];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
[self.downloader.sessionManager invalidateSessionCancelingTasks:YES];
|
||||
[self.downloader.sessionManager invalidateSessionCancelingTasks:YES resetSession:NO];
|
||||
self.downloader = nil;
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
[super tearDown];
|
||||
@ -561,7 +561,7 @@
|
||||
|
||||
@implementation MockAFAutoPurgingImageCache
|
||||
|
||||
-(BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
|
||||
- (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
|
||||
if (self.shouldCache) {
|
||||
return self.shouldCache(image, request, identifier);
|
||||
}
|
||||
@ -570,7 +570,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
-(void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier{
|
||||
- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier{
|
||||
[super addImage:image withIdentifier:identifier];
|
||||
if (self.addCache) {
|
||||
self.addCache(image, identifier);
|
||||
|
||||
@ -177,7 +177,7 @@ static NSData * AFJSONTestData() {
|
||||
- (void)testThatJSONRemovesKeysWithNullValues {
|
||||
self.responseSerializer.removesKeysWithNullValues = YES;
|
||||
NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type":@"text/json"}];
|
||||
NSData *data = [NSJSONSerialization dataWithJSONObject:@{@"key":@"value",@"nullkey":[NSNull null],@"array":@[@{@"subnullkey":[NSNull null]}]}
|
||||
NSData *data = [NSJSONSerialization dataWithJSONObject:@{@"key":@"value",@"nullkey":[NSNull null],@"array":@[@{@"subnullkey":[NSNull null]}], @"arrayWithNulls": @[[NSNull null]]}
|
||||
options:(NSJSONWritingOptions)0
|
||||
error:nil];
|
||||
|
||||
@ -189,6 +189,7 @@ static NSData * AFJSONTestData() {
|
||||
XCTAssertNotNil(responseObject[@"key"]);
|
||||
XCTAssertNil(responseObject[@"nullkey"]);
|
||||
XCTAssertNil(responseObject[@"array"][0][@"subnullkey"]);
|
||||
XCTAssertEqualObjects(responseObject[@"arrayWithNulls"], @[]);
|
||||
}
|
||||
|
||||
- (void)testThatJSONResponseSerializerCanBeCopied {
|
||||
|
||||
@ -46,7 +46,8 @@
|
||||
[super tearDown];
|
||||
self.networkActivityIndicatorManager = nil;
|
||||
|
||||
[self.sessionManager invalidateSessionCancelingTasks:YES];
|
||||
[self.sessionManager invalidateSessionCancelingTasks:YES resetSession:NO];
|
||||
self.sessionManager = nil;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
@ -69,6 +70,7 @@
|
||||
[self.sessionManager
|
||||
GET:@"/delay/1"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
|
||||
[requestExpectation fulfill];
|
||||
@ -95,6 +97,7 @@
|
||||
[self.sessionManager
|
||||
GET:@"/status/404"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:nil
|
||||
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
@ -128,6 +131,7 @@
|
||||
[self.sessionManager
|
||||
GET:@"/delay/2"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
|
||||
requestEndTime = CACurrentMediaTime();
|
||||
@ -157,6 +161,7 @@
|
||||
[self.sessionManager
|
||||
GET:@"/delay/4"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
|
||||
[requestExpectation fulfill];
|
||||
@ -167,6 +172,7 @@
|
||||
[self.sessionManager
|
||||
GET:@"/delay/2"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
progress:nil
|
||||
success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
|
||||
|
||||
|
||||
@ -125,4 +125,17 @@
|
||||
[self verifyReachabilityStatusBlockGetsCalledWithManager:self.domainReachability];
|
||||
}
|
||||
|
||||
- (void)testObjectPostingReachabilityManagerNotification {
|
||||
[self expectationForNotification:AFNetworkingReachabilityDidChangeNotification
|
||||
object:self.domainReachability
|
||||
handler:^BOOL(NSNotification *notification) {
|
||||
BOOL isObjectPostingNotification = [notification.object isEqual:self.domainReachability];
|
||||
return isObjectPostingNotification;
|
||||
}];
|
||||
|
||||
[self.domainReachability startMonitoring];
|
||||
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -58,23 +58,31 @@ static SecTrustRef AFUTADNNetServerTrust() {
|
||||
}
|
||||
|
||||
static SecCertificateRef AFUTHTTPBinOrgCertificate() {
|
||||
NSString *certPath = [[NSBundle bundleForClass:[AFSecurityPolicyTests class]] pathForResource:@"httpbinorg_06102018" ofType:@"cer"];
|
||||
NSString *certPath = [[NSBundle bundleForClass:[AFSecurityPolicyTests class]] pathForResource:@"httpbinorg_03172020" ofType:@"cer"];
|
||||
NSCAssert(certPath != nil, @"Path for certificate should not be nil");
|
||||
NSData *certData = [NSData dataWithContentsOfFile:certPath];
|
||||
|
||||
return SecCertificateCreateWithData(NULL, (__bridge CFDataRef)(certData));
|
||||
}
|
||||
|
||||
static SecCertificateRef AFUTLetsEncryptAuthorityCertificate() {
|
||||
NSString *certPath = [[NSBundle bundleForClass:NSClassFromString(@"AFSecurityPolicyTests")] pathForResource:@"Let's Encrypt Authority X3" ofType:@"cer"];
|
||||
static SecCertificateRef AFUTAmazonAuthorityCertificate() {
|
||||
NSString *certPath = [[NSBundle bundleForClass:NSClassFromString(@"AFSecurityPolicyTests")] pathForResource:@"Amazon" ofType:@"cer"];
|
||||
NSCAssert(certPath != nil, @"Path for certificate should not be nil");
|
||||
NSData *certData = [NSData dataWithContentsOfFile:certPath];
|
||||
|
||||
return SecCertificateCreateWithData(NULL, (__bridge CFDataRef)(certData));
|
||||
}
|
||||
|
||||
static SecCertificateRef AFUTDSTRootCertificate() {
|
||||
NSString *certPath = [[NSBundle bundleForClass:NSClassFromString(@"AFSecurityPolicyTests")] pathForResource:@"DST Root CA X3" ofType:@"cer"];
|
||||
static SecCertificateRef AFUTAmazonRootAuthorityCertificate() {
|
||||
NSString *certPath = [[NSBundle bundleForClass:NSClassFromString(@"AFSecurityPolicyTests")] pathForResource:@"Amazon Root CA 1" ofType:@"cer"];
|
||||
NSCAssert(certPath != nil, @"Path for certificate should not be nil");
|
||||
NSData *certData = [NSData dataWithContentsOfFile:certPath];
|
||||
|
||||
return SecCertificateCreateWithData(NULL, (__bridge CFDataRef)(certData));
|
||||
}
|
||||
|
||||
static SecCertificateRef AFUTStarfieldServicesRootCertificate() {
|
||||
NSString *certPath = [[NSBundle bundleForClass:NSClassFromString(@"AFSecurityPolicyTests")] pathForResource:@"Starfield Services Root Certificate Authority - G2" ofType:@"cer"];
|
||||
NSCAssert(certPath != nil, @"Path for certificate should not be nil");
|
||||
NSData *certData = [NSData dataWithContentsOfFile:certPath];
|
||||
|
||||
@ -204,7 +212,7 @@ static SecTrustRef AFUTTrustWithCertificate(SecCertificateRef certificate) {
|
||||
- (void)testPolicyWithPublicKeyPinningAllowsHTTPBinOrgServerTrustWithHTTPBinOrgIntermediateCertificatePinned {
|
||||
AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey];
|
||||
|
||||
SecCertificateRef certificate = AFUTLetsEncryptAuthorityCertificate();
|
||||
SecCertificateRef certificate = AFUTAmazonAuthorityCertificate();
|
||||
policy.pinnedCertificates = [NSSet setWithObject:(__bridge_transfer id)SecCertificateCopyData(certificate)];
|
||||
XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow server trust");
|
||||
}
|
||||
@ -212,7 +220,7 @@ static SecTrustRef AFUTTrustWithCertificate(SecCertificateRef certificate) {
|
||||
- (void)testPolicyWithPublicKeyPinningAllowsHTTPBinOrgServerTrustWithHTTPBinOrgRootCertificatePinned {
|
||||
AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey];
|
||||
|
||||
SecCertificateRef certificate = AFUTDSTRootCertificate();
|
||||
SecCertificateRef certificate = AFUTAmazonRootAuthorityCertificate();
|
||||
policy.pinnedCertificates = [NSSet setWithObject:(__bridge_transfer id)SecCertificateCopyData(certificate)];
|
||||
XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow server trust");
|
||||
}
|
||||
@ -221,10 +229,12 @@ static SecTrustRef AFUTTrustWithCertificate(SecCertificateRef certificate) {
|
||||
AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey];
|
||||
|
||||
SecCertificateRef httpBinCertificate = AFUTHTTPBinOrgCertificate();
|
||||
SecCertificateRef intermediateCertificate = AFUTLetsEncryptAuthorityCertificate();
|
||||
SecCertificateRef rootCertificate = AFUTDSTRootCertificate();
|
||||
SecCertificateRef intermediateCertificate = AFUTAmazonAuthorityCertificate();
|
||||
SecCertificateRef intermediateCertificate2 = AFUTAmazonRootAuthorityCertificate();
|
||||
SecCertificateRef rootCertificate = AFUTStarfieldServicesRootCertificate();
|
||||
[policy setPinnedCertificates:[NSSet setWithObjects:(__bridge_transfer NSData *)SecCertificateCopyData(httpBinCertificate),
|
||||
(__bridge_transfer NSData *)SecCertificateCopyData(intermediateCertificate),
|
||||
(__bridge_transfer NSData *)SecCertificateCopyData(intermediateCertificate2),
|
||||
(__bridge_transfer NSData *)SecCertificateCopyData(rootCertificate), nil]];
|
||||
XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow HTTPBinOrg server trust because at least one of the pinned certificates is valid");
|
||||
|
||||
@ -316,7 +326,7 @@ static SecTrustRef AFUTTrustWithCertificate(SecCertificateRef certificate) {
|
||||
- (void)testPolicyWithCertificatePinningAllowsHTTPBinOrgServerTrustWithHTTPBinOrgIntermediateCertificatePinned {
|
||||
AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
|
||||
|
||||
SecCertificateRef certificate = AFUTLetsEncryptAuthorityCertificate();
|
||||
SecCertificateRef certificate = AFUTAmazonAuthorityCertificate();
|
||||
policy.pinnedCertificates = [NSSet setWithObject:(__bridge_transfer id)SecCertificateCopyData(certificate)];
|
||||
XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow server trust");
|
||||
}
|
||||
@ -324,7 +334,7 @@ static SecTrustRef AFUTTrustWithCertificate(SecCertificateRef certificate) {
|
||||
- (void)testPolicyWithCertificatePinningAllowsHTTPBinOrgServerTrustWithHTTPBinOrgRootCertificatePinned {
|
||||
AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
|
||||
|
||||
SecCertificateRef certificate = AFUTDSTRootCertificate();
|
||||
SecCertificateRef certificate = AFUTAmazonRootAuthorityCertificate();
|
||||
policy.pinnedCertificates = [NSSet setWithObject:(__bridge_transfer id)SecCertificateCopyData(certificate)];
|
||||
XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow server trust");
|
||||
}
|
||||
@ -333,10 +343,12 @@ static SecTrustRef AFUTTrustWithCertificate(SecCertificateRef certificate) {
|
||||
AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
|
||||
|
||||
SecCertificateRef httpBinCertificate = AFUTHTTPBinOrgCertificate();
|
||||
SecCertificateRef intermediateCertificate = AFUTLetsEncryptAuthorityCertificate();
|
||||
SecCertificateRef rootCertificate = AFUTDSTRootCertificate();
|
||||
SecCertificateRef intermediateCertificate = AFUTAmazonAuthorityCertificate();
|
||||
SecCertificateRef intermediateCertificate2 = AFUTAmazonRootAuthorityCertificate();
|
||||
SecCertificateRef rootCertificate = AFUTStarfieldServicesRootCertificate();
|
||||
[policy setPinnedCertificates:[NSSet setWithObjects:(__bridge_transfer NSData *)SecCertificateCopyData(httpBinCertificate),
|
||||
(__bridge_transfer NSData *)SecCertificateCopyData(intermediateCertificate),
|
||||
(__bridge_transfer NSData *)SecCertificateCopyData(intermediateCertificate2),
|
||||
(__bridge_transfer NSData *)SecCertificateCopyData(rootCertificate), nil]];
|
||||
XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow HTTPBinOrg server trust because at least one of the pinned certificates is valid");
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
[self.sessionManager invalidateSessionCancelingTasks:YES];
|
||||
[self.sessionManager invalidateSessionCancelingTasks:YES resetSession:NO];
|
||||
self.sessionManager = nil;
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
[self.sessionManager invalidateSessionCancelingTasks:YES];
|
||||
[self.sessionManager invalidateSessionCancelingTasks:YES resetSession:NO];
|
||||
self.sessionManager = nil;
|
||||
}
|
||||
|
||||
|
||||
@ -64,22 +64,22 @@
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testProgressIsSet {
|
||||
NSProgress* progress = nil;
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
[self.webView
|
||||
loadRequest:self.HTMLRequest
|
||||
progress:&progress
|
||||
success:^NSString * _Nonnull(NSHTTPURLResponse * _Nonnull response, NSString * _Nonnull HTML) {
|
||||
[expectation fulfill];
|
||||
return HTML;
|
||||
}
|
||||
failure:nil];
|
||||
[self keyValueObservingExpectationForObject:progress
|
||||
keyPath:@"fractionCompleted"
|
||||
expectedValue:@(1.0)];
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
//- (void)testProgressIsSet {
|
||||
// NSProgress* progress = nil;
|
||||
// XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
|
||||
// [self.webView
|
||||
// loadRequest:self.HTMLRequest
|
||||
// progress:&progress
|
||||
// success:^NSString * _Nonnull(NSHTTPURLResponse * _Nonnull response, NSString * _Nonnull HTML) {
|
||||
// [expectation fulfill];
|
||||
// return HTML;
|
||||
// }
|
||||
// failure:nil];
|
||||
// [self keyValueObservingExpectationForObject:progress
|
||||
// keyPath:@"fractionCompleted"
|
||||
// expectedValue:@(1.0)];
|
||||
// [self waitForExpectationsWithCommonTimeout];
|
||||
//}
|
||||
|
||||
- (void)testRequestWithCustomHeaders {
|
||||
NSMutableURLRequest *customHeaderRequest = [NSMutableURLRequest requestWithURL:[self.baseURL URLByAppendingPathComponent:@"headers"]];
|
||||
|
||||
@ -70,10 +70,10 @@
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
[self.localManager.session.configuration.URLCache removeAllCachedResponses];
|
||||
[self.localManager invalidateSessionCancelingTasks:YES];
|
||||
[self.localManager invalidateSessionCancelingTasks:YES resetSession:NO];
|
||||
self.localManager = nil;
|
||||
|
||||
[self.backgroundManager invalidateSessionCancelingTasks:YES];
|
||||
[self.backgroundManager invalidateSessionCancelingTasks:YES resetSession:NO];
|
||||
self.backgroundManager = nil;
|
||||
}
|
||||
|
||||
@ -133,19 +133,44 @@
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
// iOS 7 has a bug that may return nil for a session. To simulate that, nil out the
|
||||
// session and it will return nil itself.
|
||||
- (void)testFileUploadTaskReturnsNilWithBug {
|
||||
[self.localManager setValue:nil forKey:@"session"];
|
||||
- (void)testSessionTaskDoesReportMetrics {
|
||||
[self expectationForNotification:AFNetworkingTaskDidCompleteNotification object:nil handler:^BOOL(NSNotification * _Nonnull notification) {
|
||||
#if AF_CAN_USE_AT_AVAILABLE && AF_CAN_INCLUDE_SESSION_TASK_METRICS
|
||||
if (@available(iOS 10, macOS 10.12, watchOS 3, tvOS 10, *)) {
|
||||
return [notification userInfo][AFNetworkingTaskDidCompleteSessionTaskMetrics] != nil;
|
||||
}
|
||||
#endif
|
||||
return YES;
|
||||
}];
|
||||
|
||||
#if AF_CAN_INCLUDE_SESSION_TASK_METRICS
|
||||
__weak XCTestExpectation *metricsBlock = [self expectationWithDescription:@"Metrics completion block is called"];
|
||||
[self.localManager setTaskDidFinishCollectingMetricsBlock:^(NSURLSession * _Nonnull session, NSURLSessionTask * _Nonnull task, NSURLSessionTaskMetrics * _Nullable metrics) {
|
||||
[metricsBlock fulfill];
|
||||
}];
|
||||
#endif
|
||||
|
||||
NSURLSessionTask *task = [self.localManager downloadTaskWithRequest:[self bigImageURLRequest]
|
||||
progress:nil
|
||||
destination:nil
|
||||
completionHandler:nil];
|
||||
[task resume];
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)testSessionIsStillValid {
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnonnull"
|
||||
XCTAssertNil([self.localManager uploadTaskWithRequest:[NSURLRequest requestWithURL:self.baseURL]
|
||||
fromFile:nil
|
||||
progress:NULL
|
||||
completionHandler:NULL],
|
||||
@"Upload task should be nil.");
|
||||
#pragma GCC diagnostic pop
|
||||
NSURLSession *session = self.localManager.session;
|
||||
[self.localManager invalidateSessionCancelingTasks:YES resetSession:NO];
|
||||
|
||||
XCTAssertEqual(session, self.localManager.session);
|
||||
}
|
||||
|
||||
- (void)testSessionRecreatesAgain {
|
||||
|
||||
[self.localManager invalidateSessionCancelingTasks:YES resetSession:YES];
|
||||
|
||||
XCTAssertNotNil(self.localManager.session);
|
||||
}
|
||||
|
||||
- (void)testUploadTaskDoesReportProgress {
|
||||
@ -473,7 +498,7 @@
|
||||
return [NSURLRequest requestWithURL:self.delayURL];
|
||||
}
|
||||
|
||||
- (IMP)_implementationForTask:(NSURLSessionTask *)task selector:(SEL)selector {
|
||||
- (IMP)_implementationForTask:(NSURLSessionTask *)task selector:(SEL)selector {
|
||||
return [self _implementationForClass:[task class] selector:selector];
|
||||
}
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
@interface AFCachedImage : NSObject
|
||||
|
||||
@property (nonatomic, strong) UIImage *image;
|
||||
@property (nonatomic, strong) NSString *identifier;
|
||||
@property (nonatomic, copy) NSString *identifier;
|
||||
@property (nonatomic, assign) UInt64 totalBytes;
|
||||
@property (nonatomic, strong) NSDate *lastAccessDate;
|
||||
@property (nonatomic, assign) UInt64 currentMemoryUsage;
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
@implementation AFCachedImage
|
||||
|
||||
-(instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier {
|
||||
- (instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier {
|
||||
if (self = [self init]) {
|
||||
self.image = image;
|
||||
self.identifier = identifier;
|
||||
@ -51,7 +51,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (UIImage*)accessImage {
|
||||
- (UIImage *)accessImage {
|
||||
self.lastAccessDate = [NSDate date];
|
||||
return self.image;
|
||||
}
|
||||
@ -134,7 +134,7 @@
|
||||
[self.cachedImages removeObjectForKey:cachedImage.identifier];
|
||||
bytesPurged += cachedImage.totalBytes;
|
||||
if (bytesPurged >= bytesToPurge) {
|
||||
break ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
self.currentMemoryUsage -= bytesPurged;
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
|
||||
@interface AFImageDownloaderResponseHandler : NSObject
|
||||
@property (nonatomic, strong) NSUUID *uuid;
|
||||
@property (nonatomic, copy) void (^successBlock)(NSURLRequest*, NSHTTPURLResponse*, UIImage*);
|
||||
@property (nonatomic, copy) void (^failureBlock)(NSURLRequest*, NSHTTPURLResponse*, NSError*);
|
||||
@property (nonatomic, copy) void (^successBlock)(NSURLRequest *, NSHTTPURLResponse *, UIImage *);
|
||||
@property (nonatomic, copy) void (^failureBlock)(NSURLRequest *, NSHTTPURLResponse *, NSError *);
|
||||
@end
|
||||
|
||||
@implementation AFImageDownloaderResponseHandler
|
||||
@ -71,11 +71,11 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)addResponseHandler:(AFImageDownloaderResponseHandler*)handler {
|
||||
- (void)addResponseHandler:(AFImageDownloaderResponseHandler *)handler {
|
||||
[self.responseHandlers addObject:handler];
|
||||
}
|
||||
|
||||
- (void)removeResponseHandler:(AFImageDownloaderResponseHandler*)handler {
|
||||
- (void)removeResponseHandler:(AFImageDownloaderResponseHandler *)handler {
|
||||
[self.responseHandlers removeObject:handler];
|
||||
}
|
||||
|
||||
@ -254,14 +254,14 @@
|
||||
completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
|
||||
dispatch_async(self.responseQueue, ^{
|
||||
__strong __typeof__(weakSelf) strongSelf = weakSelf;
|
||||
AFImageDownloaderMergedTask *mergedTask = strongSelf.mergedTasks[URLIdentifier];
|
||||
AFImageDownloaderMergedTask *mergedTask = [strongSelf safelyGetMergedTask:URLIdentifier];
|
||||
if ([mergedTask.identifier isEqual:mergedTaskIdentifier]) {
|
||||
mergedTask = [strongSelf safelyRemoveMergedTaskWithURLIdentifier:URLIdentifier];
|
||||
if (error) {
|
||||
for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) {
|
||||
if (handler.failureBlock) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
handler.failureBlock(request, (NSHTTPURLResponse*)response, error);
|
||||
handler.failureBlock(request, (NSHTTPURLResponse *)response, error);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -273,7 +273,7 @@
|
||||
for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) {
|
||||
if (handler.successBlock) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
handler.successBlock(request, (NSHTTPURLResponse*)response, responseObject);
|
||||
handler.successBlock(request, (NSHTTPURLResponse *)response, responseObject);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -340,7 +340,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (AFImageDownloaderMergedTask*)safelyRemoveMergedTaskWithURLIdentifier:(NSString *)URLIdentifier {
|
||||
- (AFImageDownloaderMergedTask *)safelyRemoveMergedTaskWithURLIdentifier:(NSString *)URLIdentifier {
|
||||
__block AFImageDownloaderMergedTask *mergedTask = nil;
|
||||
dispatch_sync(self.synchronizationQueue, ^{
|
||||
mergedTask = [self removeMergedTaskWithURLIdentifier:URLIdentifier];
|
||||
@ -404,6 +404,14 @@
|
||||
return self.activeRequestCount < self.maximumActiveDownloads;
|
||||
}
|
||||
|
||||
- (AFImageDownloaderMergedTask *)safelyGetMergedTask:(NSString *)URLIdentifier {
|
||||
__block AFImageDownloaderMergedTask *mergedTask;
|
||||
dispatch_sync(self.synchronizationQueue, ^(){
|
||||
mergedTask = self.mergedTasks[URLIdentifier];
|
||||
});
|
||||
return mergedTask;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
@ -103,11 +103,11 @@ static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState
|
||||
|
||||
+ (AFImageDownloader *)sharedImageDownloader {
|
||||
|
||||
return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
|
||||
return objc_getAssociatedObject([UIButton class], @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
|
||||
}
|
||||
|
||||
+ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
|
||||
objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
objc_setAssociatedObject([UIButton class], @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
@ -168,7 +168,7 @@ static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState
|
||||
if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
|
||||
if (success) {
|
||||
success(request, response, responseObject);
|
||||
} else if(responseObject) {
|
||||
} else if (responseObject) {
|
||||
[strongSelf setImage:responseObject forState:state];
|
||||
}
|
||||
[strongSelf af_setImageDownloadReceipt:nil forState:state];
|
||||
@ -247,7 +247,7 @@ static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState
|
||||
if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
|
||||
if (success) {
|
||||
success(request, response, responseObject);
|
||||
} else if(responseObject) {
|
||||
} else if (responseObject) {
|
||||
[strongSelf setBackgroundImage:responseObject forState:state];
|
||||
}
|
||||
[strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state];
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
@interface UIImage (AFNetworking)
|
||||
|
||||
+ (UIImage*) safeImageWithData:(NSData*)data;
|
||||
+ (UIImage *)safeImageWithData:(NSData *)data;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -48,11 +48,11 @@
|
||||
@implementation UIImageView (AFNetworking)
|
||||
|
||||
+ (AFImageDownloader *)sharedImageDownloader {
|
||||
return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
|
||||
return objc_getAssociatedObject([UIImageView class], @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
|
||||
}
|
||||
|
||||
+ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
|
||||
objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
objc_setAssociatedObject([UIImageView class], @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
@ -75,7 +75,6 @@
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
|
||||
{
|
||||
|
||||
if ([urlRequest URL] == nil) {
|
||||
self.image = placeholderImage;
|
||||
if (failure) {
|
||||
@ -85,7 +84,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){
|
||||
if ([self isActiveTaskURLEqualToURLRequest:urlRequest]) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -119,7 +118,7 @@
|
||||
if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) {
|
||||
if (success) {
|
||||
success(request, response, responseObject);
|
||||
} else if(responseObject) {
|
||||
} else if (responseObject) {
|
||||
strongSelf.image = responseObject;
|
||||
}
|
||||
[strongSelf clearActiveDownloadInformation];
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
|
||||
@implementation UIWebView (AFNetworking)
|
||||
|
||||
- (AFHTTPSessionManager *)sessionManager {
|
||||
- (AFHTTPSessionManager *)sessionManager {
|
||||
static AFHTTPSessionManager *_af_defaultHTTPSessionManager = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
AF_IOS_SDK=iphonesimulator11.3
|
||||
AF_MAC_SDK=macosx10.13
|
||||
AF_TVOS_SDK=appletvsimulator11.3
|
||||
AF_IOS_SDK=iphonesimulator13.0
|
||||
AF_MAC_SDK=macosx10.15
|
||||
AF_TVOS_SDK=appletvsimulator13.0
|
||||
|
||||
AF_CONFIGURATION=Release
|
||||
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
SCAN_DEVICE="iPhone 7"
|
||||
SCAN_SDK="iphonesimulator10.3"
|
||||
EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 7"
|
||||
@ -1,3 +1,3 @@
|
||||
SCAN_DEVICE="iPhone 8"
|
||||
SCAN_SDK=$AF_IOS_SDK
|
||||
SCAN_SDK=iphonesimulator11.3
|
||||
EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 8"
|
||||
|
||||
3
fastlane/.env.ios11_xcode94
Normal file
3
fastlane/.env.ios11_xcode94
Normal file
@ -0,0 +1,3 @@
|
||||
SCAN_DEVICE="iPhone 8"
|
||||
SCAN_SDK=iphonesimulator11.4
|
||||
EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 8"
|
||||
3
fastlane/.env.ios12_xcode10
Normal file
3
fastlane/.env.ios12_xcode10
Normal file
@ -0,0 +1,3 @@
|
||||
SCAN_DEVICE="iPhone 8"
|
||||
SCAN_SDK=iphonesimulator12.0
|
||||
EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 8"
|
||||
3
fastlane/.env.ios13_xcode11
Normal file
3
fastlane/.env.ios13_xcode11
Normal file
@ -0,0 +1,3 @@
|
||||
SCAN_DEVICE="iPhone 8"
|
||||
SCAN_SDK=$AF_IOS_SDK
|
||||
EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 8"
|
||||
@ -1,3 +0,0 @@
|
||||
SCAN_DEVICE="iPhone 5"
|
||||
SCAN_SDK=iphonesimulator9.3
|
||||
EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 5,OS=8.1"
|
||||
@ -1,3 +0,0 @@
|
||||
SCAN_DEVICE="iPhone 6s"
|
||||
SCAN_SDK=iphonesimulator9.3
|
||||
EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 6s"
|
||||
@ -1,5 +1,5 @@
|
||||
SCAN_SCHEME=$AF_OSX_FRAMEWORK_SCHEME
|
||||
SCAN_SDK=$AF_OSX_SDK
|
||||
SCAN_SDK="macosx10.15"
|
||||
|
||||
EXAMPLE_SCHEME=$AF_OSX_EXAMPLE_SCHEME
|
||||
EXAMPLE_DESTINATION="platform=macOS"
|
||||
EXAMPLE_DESTINATION="platform=macOS"
|
||||
Loading…
Reference in New Issue
Block a user