Toggle navigation
Toggle navigation
This project
Loading...
Sign in
iOS
/
asi-http-request
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Ben Copsey
2009-08-11 13:53:15 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a7d73a6f4ec1d81442d60ab24fc66202b5f1f774
a7d73a6f
1 parent
cc832d72
Fix throttling on iPhone
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletions
Classes/ASIHTTPRequest.m
Classes/ASIHTTPRequest.m
View file @
a7d73a6
...
...
@@ -73,6 +73,8 @@ unsigned long const ASIWWANBandwidthThrottleAmount = 14800;
// It will be set to NO when throttling was turned on with setShouldThrottleBandwidthForWWAN, but a WI-FI connection is active
BOOL
isBandwidthThrottled
=
NO
;
BOOL
shouldThrottleBandwithForWWANOnly
=
NO
;
static
NSLock
*
sessionCookiesLock
=
nil
;
// Private stuff
...
...
@@ -2328,7 +2330,8 @@ static NSLock *sessionCookiesLock = nil;
{
#if TARGET_OS_IPHONE
[
bandwidthThrottlingLock
lock
];
BOOL
throttle
=
isBandwidthThrottled
;
BOOL
throttle
=
isBandwidthThrottled
||
(
!
shouldThrottleBandwithForWWANOnly
&&
(
maxBandwidthPerSecond
));
[
bandwidthThrottlingLock
unlock
];
return
throttle
;
#else
...
...
@@ -2432,12 +2435,16 @@ static NSLock *sessionCookiesLock = nil;
}
else
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
@"kNetworkReachabilityChangedNotification"
object
:
nil
];
[
ASIHTTPRequest
setMaxBandwidthPerSecond
:
0
];
[
bandwidthThrottlingLock
lock
];
shouldThrottleBandwithForWWANOnly
=
NO
;
[
bandwidthThrottlingLock
unlock
];
}
}
+
(
void
)
throttleBandwidthForWWANUsingLimit
:
(
unsigned
long
)
limit
{
[
bandwidthThrottlingLock
lock
];
shouldThrottleBandwithForWWANOnly
=
YES
;
maxBandwidthPerSecond
=
limit
;
[[
Reachability
sharedReachability
]
setNetworkStatusNotificationsEnabled
:
YES
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
reachabilityChanged
:
)
name
:
@"kNetworkReachabilityChangedNotification"
object
:
nil
];
...
...
Please
register
or
login
to post a comment