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
2010-11-13 13:35:16 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0d9fa924dee89099e36658a0f1ca49cdafda4a42
0d9fa924
1 parent
4b6b9af2
Added new clearDelegatesAndCancel method
Fix leak in iPad sample
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
3 deletions
Classes/ASIHTTPRequest.h
Classes/ASIHTTPRequest.m
iPhone Sample/WebPageViewController.m
Classes/ASIHTTPRequest.h
View file @
0d9fa92
...
...
@@ -583,7 +583,8 @@ typedef void (^ASIDataBlock)(NSData *data);
// Run request in the background
-
(
void
)
startAsynchronous
;
// Clears all delegates and blocks, then cancels the request
-
(
void
)
clearDelegatesAndCancel
;
#pragma mark HEAD request
...
...
Classes/ASIHTTPRequest.m
View file @
0d9fa92
...
...
@@ -24,7 +24,7 @@
#import "ASIDataCompressor.h"
// Automatically set on build
NSString
*
ASIHTTPRequestVersion
=
@"v1.7-13
7 2010-11-10
"
;
NSString
*
ASIHTTPRequestVersion
=
@"v1.7-13
9 2010-11-13
"
;
NSString
*
const
NetworkRequestErrorDomain
=
@"ASIHTTPRequestErrorDomain"
;
...
...
@@ -375,36 +375,58 @@ static NSOperationQueue *sharedQueue = nil;
NSMutableArray
*
blocks
=
[
NSMutableArray
array
];
if
(
completionBlock
)
{
[
blocks
addObject
:
completionBlock
];
[
completionBlock
release
];
completionBlock
=
nil
;
}
if
(
failureBlock
)
{
[
blocks
addObject
:
failureBlock
];
[
failureBlock
release
];
failureBlock
=
nil
;
}
if
(
startedBlock
)
{
[
blocks
addObject
:
startedBlock
];
[
startedBlock
release
];
startedBlock
=
nil
;
}
if
(
headersReceivedBlock
)
{
[
blocks
addObject
:
headersReceivedBlock
];
[
headersReceivedBlock
release
];
headersReceivedBlock
=
nil
;
}
if
(
bytesReceivedBlock
)
{
[
blocks
addObject
:
bytesReceivedBlock
];
[
bytesReceivedBlock
release
];
bytesReceivedBlock
=
nil
;
}
if
(
bytesSentBlock
)
{
[
blocks
addObject
:
bytesSentBlock
];
[
bytesSentBlock
release
];
bytesSentBlock
=
nil
;
}
if
(
downloadSizeIncrementedBlock
)
{
[
blocks
addObject
:
downloadSizeIncrementedBlock
];
[
downloadSizeIncrementedBlock
release
];
downloadSizeIncrementedBlock
=
nil
;
}
if
(
uploadSizeIncrementedBlock
)
{
[
blocks
addObject
:
uploadSizeIncrementedBlock
];
[
uploadSizeIncrementedBlock
release
];
uploadSizeIncrementedBlock
=
nil
;
}
if
(
dataReceivedBlock
)
{
[
blocks
addObject
:
dataReceivedBlock
];
[
dataReceivedBlock
release
];
dataReceivedBlock
=
nil
;
}
if
(
proxyAuthenticationNeededBlock
)
{
[
blocks
addObject
:
proxyAuthenticationNeededBlock
];
[
proxyAuthenticationNeededBlock
release
];
proxyAuthenticationNeededBlock
=
nil
;
}
if
(
authenticationNeededBlock
)
{
[
blocks
addObject
:
authenticationNeededBlock
];
[
authenticationNeededBlock
release
];
authenticationNeededBlock
=
nil
;
}
[[
self
class
]
performSelectorOnMainThread
:
@selector
(
releaseBlocks
:)
withObject
:
blocks
waitUntilDone
:
[
NSThread
isMainThread
]];
}
...
...
@@ -648,6 +670,23 @@ static NSOperationQueue *sharedQueue = nil;
[
self
performSelector
:
@selector
(
cancelOnRequestThread
)
onThread
:[[
self
class
]
threadForRequest
:
self
]
withObject
:
nil
waitUntilDone
:
NO
];
}
-
(
void
)
clearDelegatesAndCancel
{
[[
self
cancelledLock
]
lock
];
// Clear delegates
[
self
setDelegate
:
nil
];
[
self
setQueue
:
nil
];
[
self
setDownloadProgressDelegate
:
nil
];
[
self
setUploadProgressDelegate
:
nil
];
// Clear blocks
[
self
releaseBlocksOnMainThread
];
[[
self
cancelledLock
]
unlock
];
[
self
cancel
];
}
-
(
BOOL
)
isCancelled
{
...
...
@@ -1891,7 +1930,6 @@ static NSOperationQueue *sharedQueue = nil;
}
#if NS_BLOCKS_AVAILABLE
if
(
completionBlock
){
__block
ASIHTTPRequest
*
blockCopy
=
self
;
completionBlock
();
}
#endif
...
...
iPhone Sample/WebPageViewController.m
View file @
0d9fa92
...
...
@@ -141,6 +141,7 @@
[
webView
release
];
[
responseField
release
];
[
urlField
release
];
[
requestsInProgress
release
];
[
super
dealloc
];
}
...
...
Please
register
or
login
to post a comment