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
2011-08-20 11:21:33 +0100
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
1a57f92b8bd2f8a58629f856834baeb661f16843
1a57f92b
2 parents
762c38c0
1a7ae810
Merge branch 'master' of github.com:pokeb/asi-http-request
Conflicts: Classes/ASIHTTPRequest.m
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
7 deletions
Classes/ASIInputStream.m
Classes/CloudFiles/ASICloudFilesCDNRequest.h
Classes/CloudFiles/ASICloudFilesCDNRequest.m
Classes/CloudFiles/ASICloudFilesObjectRequest.m
Classes/CloudFiles/ASICloudFilesRequest.m
Classes/ASIInputStream.m
View file @
1a57f92
...
...
@@ -58,9 +58,11 @@ static NSLock *readLock = nil;
}
[
request
performThrottling
];
}
[
ASIHTTPRequest
incrementBandwidthUsedInLastSecond
:
toRead
];
[
readLock
unlock
];
return
[
stream
read
:
buffer
maxLength
:
toRead
];
NSInteger
rv
=
[
stream
read
:
buffer
maxLength
:
toRead
];
if
(
rv
>
0
)
[
ASIHTTPRequest
incrementBandwidthUsedInLastSecond
:
rv
];
return
rv
;
}
/*
...
...
Classes/CloudFiles/ASICloudFilesCDNRequest.h
View file @
1a57f92
...
...
@@ -24,10 +24,12 @@
// Response:
// X-CDN-Enabled: True
// X-CDN-URI: http://cdn.cloudfiles.mosso.com/c1234
// X-CDN-SSL-URI: https://cdn.ssl.cloudfiles.mosso.com/c1234
// X-CDN-TTL: 86400
+
(
id
)
containerInfoRequest
:(
NSString
*
)
containerName
;
-
(
BOOL
)
cdnEnabled
;
-
(
NSString
*
)
cdnURI
;
-
(
NSString
*
)
cdnSSLURI
;
-
(
NSUInteger
)
cdnTTL
;
...
...
Classes/CloudFiles/ASICloudFilesCDNRequest.m
View file @
1a57f92
...
...
@@ -38,15 +38,35 @@
}
-
(
BOOL
)
cdnEnabled
{
return
[[[
self
responseHeaders
]
objectForKey
:
@"X-Cdn-Enabled"
]
boolValue
];
NSNumber
*
enabled
=
[[
self
responseHeaders
]
objectForKey
:
@"X-CDN-Enabled"
];
if
(
!
enabled
)
{
enabled
=
[[
self
responseHeaders
]
objectForKey
:
@"X-Cdn-Enabled"
];
}
return
[
enabled
boolValue
];
}
-
(
NSString
*
)
cdnURI
{
return
[[
self
responseHeaders
]
objectForKey
:
@"X-Cdn-Uri"
];
NSString
*
uri
=
[[
self
responseHeaders
]
objectForKey
:
@"X-CDN-URI"
];
if
(
!
uri
)
{
uri
=
[[
self
responseHeaders
]
objectForKey
:
@"X-Cdn-Uri"
];
}
return
uri
;
}
-
(
NSString
*
)
cdnSSLURI
{
NSString
*
uri
=
[[
self
responseHeaders
]
objectForKey
:
@"X-CDN-SSL-URI"
];
if
(
!
uri
)
{
uri
=
[[
self
responseHeaders
]
objectForKey
:
@"X-Cdn-Ssl-Uri"
];
}
return
uri
;
}
-
(
NSUInteger
)
cdnTTL
{
return
[[[
self
responseHeaders
]
objectForKey
:
@"X-Ttl"
]
intValue
];
NSNumber
*
ttl
=
[[
self
responseHeaders
]
objectForKey
:
@"X-TTL"
];
if
(
!
ttl
)
{
ttl
=
[[
self
responseHeaders
]
objectForKey
:
@"X-Ttl"
];
}
return
[
ttl
intValue
];
}
#pragma mark -
...
...
@@ -130,7 +150,7 @@
if
(
ttl
>
0
)
{
[
request
addRequestHeader
:
@"X-Ttl"
value
:[
NSString
stringWithFormat
:
@"%i"
,
ttl
]];
}
[
request
addRequestHeader
:
@"X-C
dn
-Enabled"
value
:
cdnEnabled
?
@"True"
:
@"False"
];
[
request
addRequestHeader
:
@"X-C
DN
-Enabled"
value
:
cdnEnabled
?
@"True"
:
@"False"
];
return
request
;
}
...
...
Classes/CloudFiles/ASICloudFilesObjectRequest.m
View file @
1a57f92
...
...
@@ -130,7 +130,7 @@
object
.
bytes
=
[[[
self
responseHeaders
]
objectForKey
:
@"Content-Length"
]
intValue
];
object
.
contentType
=
[[
self
responseHeaders
]
objectForKey
:
@"Content-Type"
];
object
.
lastModified
=
[[
self
responseHeaders
]
objectForKey
:
@"Last-Modified"
];
object
.
metadata
=
[
[
NSMutableDictionary
alloc
]
init
];
object
.
metadata
=
[
NSMutableDictionary
dictionary
];
for
(
NSString
*
key
in
[[
self
responseHeaders
]
keyEnumerator
])
{
NSRange
metaRange
=
[
key
rangeOfString
:
@"X-Object-Meta-"
];
...
...
Classes/CloudFiles/ASICloudFilesRequest.m
View file @
1a57f92
...
...
@@ -69,8 +69,14 @@ static NSRecursiveLock *accessDetailsLock = nil;
NSDictionary
*
responseHeaders
=
[
request
responseHeaders
];
authToken
=
[
responseHeaders
objectForKey
:
@"X-Auth-Token"
];
storageURL
=
[
responseHeaders
objectForKey
:
@"X-Storage-Url"
];
cdnManagementURL
=
[
responseHeaders
objectForKey
:
@"X-CDN-Management-Url"
];
// there is a bug in the Cloud Files API for some older accounts that causes
// the CDN URL to come back in a slightly different header
if
(
!
cdnManagementURL
)
{
cdnManagementURL
=
[
responseHeaders
objectForKey
:
@"X-Cdn-Management-Url"
];
}
}
[
accessDetailsLock
unlock
];
return
[
request
error
];
}
...
...
Please
register
or
login
to post a comment