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-24 12:36:20 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7a20b032aeecf31507ad18a6bd8e3e6942e7bc23
7a20b032
1 parent
7854297b
Prevent delegate auth from being used when running on main thread
Added a test for same
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
Classes/ASIHTTPRequest.m
Classes/Tests/ASIHTTPRequestTests.h
Classes/Tests/ASIHTTPRequestTests.m
Classes/ASIHTTPRequest.m
View file @
7a20b03
...
...
@@ -1453,6 +1453,11 @@ static NSRecursiveLock *delegateAuthenticationLock = nil;
-
(
BOOL
)
askDelegateForProxyCredentials
{
// Can't use delegate authentication when running on the main thread
if
([
NSThread
isMainThread
])
{
return
NO
;
}
// If we have a delegate, we'll see if it can handle proxyAuthenticationNeededForRequest:.
// Otherwise, we'll try the queue (if this request is part of one) and it will pass the message on to its own delegate
id
authenticationDelegate
=
[
self
delegate
];
...
...
@@ -1635,6 +1640,11 @@ static NSRecursiveLock *delegateAuthenticationLock = nil;
-
(
BOOL
)
askDelegateForCredentials
{
// Can't use delegate authentication when running on the main thread
if
([
NSThread
isMainThread
])
{
return
NO
;
}
// If we have a delegate, we'll see if it can handle proxyAuthenticationNeededForRequest:.
// Otherwise, we'll try the queue (if this request is part of one) and it will pass the message on to its own delegate
id
authenticationDelegate
=
[
self
delegate
];
...
...
Classes/Tests/ASIHTTPRequestTests.h
View file @
7a20b03
...
...
@@ -39,4 +39,5 @@
-
(
void
)
testTimeOutWithoutDownloadDelegate
;
-
(
void
)
testThrottlingDownloadBandwidth
;
-
(
void
)
testThrottlingUploadBandwidth
;
-
(
void
)
testMainThreadDelegateAuthenticationFailure
;
@end
...
...
Classes/Tests/ASIHTTPRequestTests.m
View file @
7a20b03
...
...
@@ -857,6 +857,28 @@
}
-
(
void
)
authenticationNeededForRequest
:
(
ASIHTTPRequest
*
)
request
{
GHAssertTrue
(
NO
,
@"Delegate asked for authentication when running on the main thread"
);
}
-
(
void
)
testMainThreadDelegateAuthenticationFailure
{
[
ASIHTTPRequest
clearSession
];
//GHUnit will not run this function on the main thread, so we'll need to move it there
[
self
performSelectorOnMainThread
:
@selector
(
fetchOnMainThread
)
withObject
:
nil
waitUntilDone
:
YES
];
}
-
(
void
)
fetchOnMainThread
{
// Ensure the delegate is not called when we are running on the main thread
ASIHTTPRequest
*
request
=
[
ASIHTTPRequest
requestWithURL
:[
NSURL
URLWithString
:
@"http://allseeing-i.com/ASIHTTPRequest/tests/basic-authentication"
]];
[
request
setDelegate
:
self
];
[
request
start
];
GHAssertNotNil
([
request
error
],
@"Failed to generate an authentication error"
);
}
@end
...
...
Please
register
or
login
to post a comment