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-10-23 17:56:29 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
25f8c54f847c4941004c7e13a97ff16e3a9793b8
25f8c54f
1 parent
8a178558
Move remaining blocks calls onto the main thread, tweaks
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
30 deletions
Classes/ASIHTTPRequest.h
Classes/ASIHTTPRequest.m
Mac.xcodeproj/project.pbxproj
Classes/ASIHTTPRequest.h
View file @
25f8c54
...
...
@@ -529,7 +529,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
-
(
void
)
setHeadersReceivedBlock
:(
ASIHTTPRequestBlock
)
aReceivedBlock
;
-
(
void
)
setCompletionBlock
:(
ASIHTTPRequestBlock
)
aCompletionBlock
;
-
(
void
)
setFailedBlock
:(
ASIHTTPRequestBlock
)
aFailedBlock
;
-
(
void
)
setBytesReceivedBlock
:(
ASIHTTPRequestProgressBlock
)
aBytesReceivedBlock
;
-
(
void
)
setBytesReceivedBlock
:(
ASIHTTPRequestProgressBlock
)
aBytesReceivedBlock
;
-
(
void
)
setBytesSentBlock
:(
ASIHTTPRequestProgressBlock
)
aBytesSentBlock
;
-
(
void
)
setDownloadSizeIncrementedBlock
:(
ASIHTTPRequestSizeBlock
)
aDownloadSizeIncrementedBlock
;
-
(
void
)
setUploadSizeIncrementedBlock
:(
ASIHTTPRequestSizeBlock
)
anUploadSizeIncrementedBlock
;
...
...
Classes/ASIHTTPRequest.m
View file @
25f8c54
...
...
@@ -24,7 +24,7 @@
#import "ASIDataCompressor.h"
// Automatically set on build
NSString
*
ASIHTTPRequestVersion
=
@"v1.7-1
19 2010-10-18
"
;
NSString
*
ASIHTTPRequestVersion
=
@"v1.7-1
20 2010-10-23
"
;
NSString
*
const
NetworkRequestErrorDomain
=
@"ASIHTTPRequestErrorDomain"
;
...
...
@@ -1433,8 +1433,6 @@ static NSOperationQueue *sharedQueue = nil;
[
self
removeTemporaryDownloadFile
];
}
[
self
removeTemporaryUncompressedDownloadFile
];
}
// Clean up any temporary file used to store request body for streaming
...
...
@@ -1576,24 +1574,22 @@ static NSOperationQueue *sharedQueue = nil;
#if NS_BLOCKS_AVAILABLE
if
(
bytesReceivedBlock
)
{
__block
ASIHTTPRequest
*
blockCopy
=
self
;
bytesReceivedBlock
(
blockCopy
,
value
,
blockCopy
->
contentLength
+
blockCopy
->
partialDownloadSize
);
[
ASIHTTPRequest
performSelector
:
@selector
(
callBytesReceivedBlockWithLength
:)
onTarget
:&
self
withObject
:
nil
amount
:&
value
];
}
#endif
[
self
setLastBytesRead
:
bytesReadSoFar
];
}
#if NS_BLOCKS_AVAILABLE
-
(
void
)
callBytesReceivedBlockWith
Bytes
:
(
unsigned
long
long
)
bytes
ofTotal
:
(
unsigned
long
long
)
total
-
(
void
)
callBytesReceivedBlockWith
Length
:
(
unsigned
long
long
)
value
{
if
(
bytesReceivedBlock
)
{
if
(
bytesReceivedBlock
)
{
__block
ASIHTTPRequest
*
blockCopy
=
self
;
bytesReceivedBlock
(
blockCopy
,
bytes
,
blockCopy
->
contentLength
+
blockCopy
->
partialDownloadSize
);
}
bytesReceivedBlock
(
blockCopy
,
value
,
blockCopy
->
contentLength
+
blockCopy
->
partialDownloadSize
);
}
}
#endif
-
(
void
)
updateUploadProgress
{
if
([
self
isCancelled
]
||
[
self
totalBytesSent
]
==
0
)
{
...
...
@@ -1631,11 +1627,20 @@ static NSOperationQueue *sharedQueue = nil;
#if NS_BLOCKS_AVAILABLE
if
(
bytesSentBlock
){
[
ASIHTTPRequest
performSelector
:
@selector
(
callBytesSentBlockWithLength
:)
onTarget
:&
self
withObject
:
nil
amount
:&
value
];
}
#endif
}
#if NS_BLOCKS_AVAILABLE
-
(
void
)
callBytesSentBlockWithLength
:
(
unsigned
long
long
)
value
{
if
(
bytesSentBlock
)
{
__block
ASIHTTPRequest
*
blockCopy
=
self
;
bytesSentBlock
(
blockCopy
,
value
,
blockCopy
->
postLength
);
}
#endif
}
#endif
-
(
void
)
incrementDownloadSizeBy
:
(
long
long
)
length
...
...
@@ -1645,12 +1650,22 @@ static NSOperationQueue *sharedQueue = nil;
#if NS_BLOCKS_AVAILABLE
if
(
downloadSizeIncrementedBlock
){
__block
ASIHTTPRequest
*
blockCopy
=
self
;
downloadSizeIncrementedBlock
(
blockCopy
,
length
);
[
ASIHTTPRequest
performSelector
:
@selector
(
callDownloadSizeIncrementedBlockWithLength
:)
onTarget
:&
self
withObject
:
nil
amount
:&
length
];
}
#endif
}
#if NS_BLOCKS_AVAILABLE
-
(
void
)
callDownloadSizeIncrementedBlockWithLength
:
(
unsigned
long
long
)
length
{
if
(
downloadSizeIncrementedBlock
)
{
__block
ASIHTTPRequest
*
blockCopy
=
self
;
downloadSizeIncrementedBlock
(
blockCopy
,
length
);
}
}
#endif
-
(
void
)
incrementUploadSizeBy
:
(
long
long
)
length
{
...
...
@@ -1659,11 +1674,20 @@ static NSOperationQueue *sharedQueue = nil;
#if NS_BLOCKS_AVAILABLE
if
(
uploadSizeIncrementedBlock
){
[
ASIHTTPRequest
performSelector
:
@selector
(
callUploadSizeIncrementedBlockWithLength
:)
onTarget
:&
self
withObject
:
nil
amount
:&
length
];
}
#endif
}
#if NS_BLOCKS_AVAILABLE
-
(
void
)
callUploadSizeIncrementedBlockWithLength
:
(
unsigned
long
long
)
length
{
if
(
uploadSizeIncrementedBlock
){
__block
ASIHTTPRequest
*
blockCopy
=
self
;
uploadSizeIncrementedBlock
(
blockCopy
,
length
);
}
#endif
}
#endif
-
(
void
)
removeUploadProgressSoFar
...
...
@@ -1675,12 +1699,13 @@ static NSOperationQueue *sharedQueue = nil;
#if NS_BLOCKS_AVAILABLE
if
(
bytesSentBlock
){
__block
ASIHTTPRequest
*
blockCopy
=
self
;
bytesSentBlock
(
blockCopy
,
progressToRemove
,
blockCopy
->
postLength
);
[
ASIHTTPRequest
performSelector
:
@selector
(
callBytesSentBlockWithLength
:)
onTarget
:&
self
withObject
:
nil
amount
:&
progressToRemove
]
;
}
#endif
}
+
(
void
)
performSelector
:
(
SEL
)
selector
onTarget
:
(
id
*
)
target
withObject
:
(
id
)
object
amount
:
(
void
*
)
amount
{
if
([
*
target
respondsToSelector
:
selector
])
{
...
...
@@ -1826,13 +1851,6 @@ static NSOperationQueue *sharedQueue = nil;
if
(
queue
&&
[
queue
respondsToSelector
:
@selector
(
request
:
willRedirectToURL
:
)])
{
[
queue
performSelector
:
@selector
(
request
:
willRedirectToURL
:
)
withObject
:
self
withObject
:
newURL
];
}
#if NS_BLOCKS_AVAILABLE
if
(
startedBlock
){
__block
ASIHTTPRequest
*
blockCopy
=
self
;
startedBlock
(
blockCopy
);
}
#endif
}
/* ALWAYS CALLED ON MAIN THREAD! */
...
...
@@ -1938,12 +1956,6 @@ static NSOperationQueue *sharedQueue = nil;
}
[
failedRequest
performSelectorOnMainThread
:
@selector
(
reportFailure
)
withObject
:
nil
waitUntilDone
:
[
NSThread
isMainThread
]];
#if NS_BLOCKS_AVAILABLE
if
(
failureBlock
)
{
failureBlock
(
self
);
}
#endif
if
(
!
inProgress
)
{
...
...
Mac.xcodeproj/project.pbxproj
View file @
25f8c54
This diff was suppressed by a .gitattributes entry.
Please
register
or
login
to post a comment