Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update url authenticate #397

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f670c1a
Update README.textile
CloudSide May 8, 2014
eafa2af
Rename README.textile to README.md
CloudSide May 8, 2014
f047312
Update README.md
CloudSide May 8, 2014
3630fc5
fixed errors and warnings
CloudSide May 8, 2014
91caf43
Set s3HOST to "sinastorage.com" on ASIS3Request and sign
CloudSide May 8, 2014
1b593ca
update
CloudSide May 9, 2014
9601a27
update
CloudSide May 11, 2014
a04882c
update
CloudSide May 12, 2014
ed1c9a6
add target: "ASIKit"
CloudSide May 12, 2014
8a9a415
framework ASIKit-iOS
May 23, 2014
fb443c6
add readme
May 23, 2014
81da470
update readme
May 26, 2014
9e56f36
update
CloudSide May 26, 2014
1e0bf49
update
May 28, 2014
4059061
update read me
May 28, 2014
9226a44
add requestForNextChunk
Jun 10, 2014
a49d37d
update for ASIS3Bucket property
Jun 27, 2014
7c0bd29
update
Jul 21, 2014
c68eda3
update change host
Jul 23, 2014
4e119a5
update readme
Jul 23, 2014
4e50704
update
Jul 23, 2014
eeb37d3
update add project SCS-iOS-Demo
Aug 18, 2014
1cd1983
SDK for Swift
Sep 9, 2014
0ee05cb
add readme
Sep 9, 2014
26ced0a
update readme
Sep 10, 2014
203f0af
update acl request
Sep 19, 2014
e594eea
update
Sep 24, 2014
04f4249
Revert 26ced0a..e594eea
CloudSide Sep 29, 2014
f0f9b4b
update
Sep 29, 2014
144b008
Merge pull request #1 from Littlebox222/master
CloudSide Sep 29, 2014
576db2a
add url authenticate
Sep 29, 2014
72b5532
update
Sep 30, 2014
7a27a6e
update
Sep 30, 2014
e3d5db4
update 精简版 authUrl
Sep 30, 2014
bf15c02
update
Oct 8, 2014
5b25e1b
Merge pull request #2 from Littlebox222/master
Oct 8, 2014
f1bceaf
update
Oct 8, 2014
42c3103
update
Oct 8, 2014
968a63f
Merge pull request #3 from Littlebox222/master
Oct 8, 2014
810ccc9
Update README.md
CloudSide May 14, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -10,4 +10,7 @@ profile
*.pbxuser
*.mode1v3
External/GHUnit/*
.svn
.svn
Products
xcuserdata/
project.xcworkspace/
46 changes: 46 additions & 0 deletions ASIKit-iOS/ASIKit-iOS-Info.plist
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.sina.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFPlugInDynamicRegisterFunction</key>
<string></string>
<key>CFPlugInDynamicRegistration</key>
<string>NO</string>
<key>CFPlugInFactories</key>
<dict>
<key>00000000-0000-0000-0000-000000000000</key>
<string>MyFactoryFunction</string>
</dict>
<key>CFPlugInTypes</key>
<dict>
<key>00000000-0000-0000-0000-000000000000</key>
<array>
<string>00000000-0000-0000-0000-000000000000</string>
</array>
</dict>
<key>CFPlugInUnloadFunction</key>
<string></string>
<key></key>
<string></string>
</dict>
</plist>
9 changes: 9 additions & 0 deletions ASIKit-iOS/ASIKit-iOS-Prefix.pch
@@ -0,0 +1,9 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
//
//#ifdef __OBJC__
// #import <Cocoa/Cocoa.h>
//#endif
38 changes: 38 additions & 0 deletions ASIKit-iOS/ASIKit.h
@@ -0,0 +1,38 @@
//
// ASIKit.h
// iPhone
//
// Created by Littlebox222 on 14-5-22.
//
//


#import <ASIKit/Reachability.h>
#import <ASIKit/ASIAuthenticationDialog.h>
#import <ASIKit/ASIHTTPRequestConfig.h>
#import <ASIKit/ASICacheDelegate.h>
#import <ASIKit/ASIHTTPRequestDelegate.h>
#import <ASIKit/ASIProgressDelegate.h>
#import <ASIKit/ASIInputStream.h>
#import <ASIKit/ASIFormDataRequest.h>
#import <ASIKit/ASIHTTPRequest.h>
#import <ASIKit/ASINetworkQueue.h>
#import <ASIKit/ASIDownloadCache.h>
#import <ASIKit/ASIDataDecompressor.h>
#import <ASIKit/ASIDataCompressor.h>
#import <ASIKit/ASIWebPageRequest.h>

#import <ASIKit/ASIS3Bucket.h>
#import <ASIKit/ASIS3BucketObject.h>
#import <ASIKit/ASIS3BucketRequest.h>
#import <ASIKit/ASIS3ObjectRequest.h>
#import <ASIKit/ASIS3ServiceRequest.h>
#import <ASIKit/ASIS3Request.h>

#import <ASIKit/ASICloudFilesCDNRequest.h>
#import <ASIKit/ASICloudFilesContainer.h>
#import <ASIKit/ASICloudFilesContainerRequest.h>
#import <ASIKit/ASICloudFilesContainerXMLParserDelegate.h>
#import <ASIKit/ASICloudFilesObject.h>
#import <ASIKit/ASICloudFilesObjectRequest.h>
#import <ASIKit/ASICloudFilesRequest.h>
2 changes: 2 additions & 0 deletions ASIKit-iOS/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

28 changes: 28 additions & 0 deletions ASIKit/ASIKit-Info.plist
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.sina.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
9 changes: 9 additions & 0 deletions ASIKit/ASIKit-Prefix.pch
@@ -0,0 +1,9 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//

#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
33 changes: 33 additions & 0 deletions ASIKit/ASIKit.h
@@ -0,0 +1,33 @@
//
// ASIKit.h
// ASIKit
//
// Created by Bruce on 14-5-12.
//
//
#import <ASIKit/ASIHTTPRequest.h>
#import <ASIKit/ASIProgressDelegate.h>
#import <ASIKit/ASIHTTPRequestDelegate.h>
#import <ASIKit/ASIInputStream.h>
#import <ASIKit/ASIFormDataRequest.h>
#import <ASIKit/ASIHTTPRequest.h>
#import <ASIKit/ASINetworkQueue.h>
#import <ASIKit/ASICacheDelegate.h>
#import <ASIKit/ASIDownloadCache.h>
#import <ASIKit/ASIDataCompressor.h>
#import <ASIKit/ASIDataDecompressor.h>
#import <ASIKit/ASIWebPageRequest.h>
#import <ASIKit/ASINSXMLParserCompat.h>
#import <ASIKit/ASICloudFilesCDNRequest.h>
#import <ASIKit/ASICloudFilesContainer.h>
#import <ASIKit/ASICloudFilesContainerRequest.h>
#import <ASIKit/ASICloudFilesContainerXMLParserDelegate.h>
#import <ASIKit/ASICloudFilesObject.h>
#import <ASIKit/ASICloudFilesObjectRequest.h>
#import <ASIKit/ASICloudFilesRequest.h>
#import <ASIKit/ASIS3Bucket.h>
#import <ASIKit/ASIS3BucketObject.h>
#import <ASIKit/ASIS3BucketRequest.h>
#import <ASIKit/ASIS3ObjectRequest.h>
#import <ASIKit/ASIS3ServiceRequest.h>
#import <ASIKit/ASIS3Request.h>
2 changes: 2 additions & 0 deletions ASIKit/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

2 changes: 1 addition & 1 deletion Build Scripts/fetch_ios_ghunit.rb
Expand Up @@ -9,6 +9,6 @@

require 'net/http'
if (!File.exists?('External/GHUnit/GHUnitIOS.framework'))
`curl -s http://allseeing-i.com/ASIHTTPRequest/GHUnit/GHUnit-IOS.zip > External/GHUnit/GHUnit-IOS.zip`
`curl -s http://sinastorage.com/sdk/GHUnit/GHUnitIOS-0.5.8.zip > External/GHUnit/GHUnit-IOS.zip`
`unzip External/GHUnit/GHUnit-IOS.zip -d External/GHUnit/ & rm External/GHUnit/GHUnit-IOS.zip`
end
2 changes: 1 addition & 1 deletion Build Scripts/fetch_mac_ghunit.rb
Expand Up @@ -9,6 +9,6 @@

require 'net/http'
if (!File.exists?('External/GHUnit/GHUnit.framework'))
`curl -s http://allseeing-i.com/ASIHTTPRequest/GHUnit/GHUnit-Mac.zip > External/GHUnit/GHUnit-Mac.zip`
`curl -s http://sinastorage.com/sdk/GHUnit/GHUnitOSX-0.5.8.zip > External/GHUnit/GHUnit-Mac.zip`
`unzip External/GHUnit/GHUnit-Mac.zip -d External/GHUnit/ & rm External/GHUnit/GHUnit-Mac.zip`
end
4 changes: 1 addition & 3 deletions Classes/ASIDataCompressor.h
Expand Up @@ -11,19 +11,17 @@
// Most of the zlib stuff is based on the sample code by Mark Adler available at http://zlib.net

#import <Foundation/Foundation.h>
#import <zlib.h>

@interface ASIDataCompressor : NSObject {
BOOL streamReady;
z_stream zStream;
}

// Convenience constructor will call setupStream for you
+ (id)compressor;

// Compress the passed chunk of data
// Passing YES for shouldFinish will finalize the deflated data - you must pass YES when you are on the last chunk of data
- (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err shouldFinish:(BOOL)shouldFinish;
- (NSData *)compressBytes:(Byte *)bytes length:(NSUInteger)length error:(NSError **)err shouldFinish:(BOOL)shouldFinish;

// Convenience method - pass it some data, and you'll get deflated data back
+ (NSData *)compressData:(NSData*)uncompressedData error:(NSError **)err;
Expand Down
7 changes: 5 additions & 2 deletions Classes/ASIDataCompressor.m
Expand Up @@ -8,11 +8,14 @@

#import "ASIDataCompressor.h"
#import "ASIHTTPRequest.h"
#import <zlib.h>

#define DATA_CHUNK_SIZE 262144 // Deal with gzipped data in 256KB chunks
#define COMPRESSION_AMOUNT Z_DEFAULT_COMPRESSION

@interface ASIDataCompressor ()
@interface ASIDataCompressor () {
z_stream zStream;
}
+ (NSError *)deflateErrorWithCode:(int)code;
@end

Expand Down Expand Up @@ -66,7 +69,7 @@ - (NSError *)closeStream
return nil;
}

- (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err shouldFinish:(BOOL)shouldFinish
- (NSData *)compressBytes:(Byte *)bytes length:(NSUInteger)length error:(NSError **)err shouldFinish:(BOOL)shouldFinish
{
if (length == 0) return nil;

Expand Down
4 changes: 1 addition & 3 deletions Classes/ASIDataDecompressor.h
Expand Up @@ -11,18 +11,16 @@
// Most of the zlib stuff is based on the sample code by Mark Adler available at http://zlib.net

#import <Foundation/Foundation.h>
#import <zlib.h>

@interface ASIDataDecompressor : NSObject {
BOOL streamReady;
z_stream zStream;
}

// Convenience constructor will call setupStream for you
+ (id)decompressor;

// Uncompress the passed chunk of data
- (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err;
- (NSData *)uncompressBytes:(Byte *)bytes length:(NSUInteger)length error:(NSError **)err;

// Convenience method - pass it some deflated data, and you'll get inflated data back
+ (NSData *)uncompressData:(NSData*)compressedData error:(NSError **)err;
Expand Down
7 changes: 5 additions & 2 deletions Classes/ASIDataDecompressor.m
Expand Up @@ -8,10 +8,13 @@

#import "ASIDataDecompressor.h"
#import "ASIHTTPRequest.h"
#import <zlib.h>

#define DATA_CHUNK_SIZE 262144 // Deal with gzipped data in 256KB chunks

@interface ASIDataDecompressor ()
@interface ASIDataDecompressor () {
z_stream zStream;
}
+ (NSError *)inflateErrorWithCode:(int)code;
@end;

Expand Down Expand Up @@ -65,7 +68,7 @@ - (NSError *)closeStream
return nil;
}

- (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err
- (NSData *)uncompressBytes:(Byte *)bytes length:(NSUInteger)length error:(NSError **)err
{
if (length == 0) return nil;

Expand Down
1 change: 1 addition & 0 deletions Classes/ASIHTTPRequest.h
Expand Up @@ -881,6 +881,7 @@ typedef void (^ASIDataBlock)(NSData *data);
// Returns a date from a string in RFC1123 format
+ (NSDate *)dateFromRFC1123String:(NSString *)string;

+ (NSString*)encodeURL:(NSString *)string;

// Used for detecting multitasking support at runtime (for backgrounding requests)
#if TARGET_OS_IPHONE
Expand Down
15 changes: 12 additions & 3 deletions Classes/ASIHTTPRequest.m
Expand Up @@ -24,7 +24,7 @@
#import "ASIDataCompressor.h"

// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.8.1-61 2011-09-19";
NSString *ASIHTTPRequestVersion = @"v1.8.2-15 2014-05-20";

static NSString *defaultUserAgent = nil;

Expand Down Expand Up @@ -4560,7 +4560,7 @@ + (void)recordBandwidthUsage
}
}
#if DEBUG_THROTTLING
ASI_DEBUG_LOG(@"[THROTTLING] ===Used: %u bytes of bandwidth in last measurement period===",bandwidthUsedInLastSecond);
ASI_DEBUG_LOG(@"[THROTTLING] ===Used: %lu bytes of bandwidth in last measurement period===",bandwidthUsedInLastSecond);
#endif
[bandwidthUsageTracker addObject:[NSNumber numberWithUnsignedLong:bandwidthUsedInLastSecond]];
[bandwidthMeasurementDate release];
Expand Down Expand Up @@ -4622,7 +4622,7 @@ + (unsigned long)maxUploadReadLength

// We'll split our bandwidth allowance into 4 (which is the default for an ASINetworkQueue's max concurrent operations count) to give all running requests a fighting chance of reading data this cycle
long long toRead = maxBandwidthPerSecond/4;
if (maxBandwidthPerSecond > 0 && (bandwidthUsedInLastSecond + toRead > maxBandwidthPerSecond)) {
if (maxBandwidthPerSecond > 0 && (bandwidthUsedInLastSecond + (unsigned long long)toRead > maxBandwidthPerSecond)) {
toRead = (long long)maxBandwidthPerSecond-(long long)bandwidthUsedInLastSecond;
if (toRead < 0) {
toRead = 0;
Expand Down Expand Up @@ -4935,6 +4935,15 @@ + (void)parseMimeType:(NSString **)mimeType andResponseEncoding:(NSStringEncodin
}
}

+ (NSString*)encodeURL:(NSString *)string
{
NSString *newString = [NSMakeCollectable(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding))) autorelease];
if (newString) {
return newString;
}
return @"";
}

#pragma mark -
#pragma mark blocks
#if NS_BLOCKS_AVAILABLE
Expand Down
8 changes: 4 additions & 4 deletions Classes/CloudFiles/ASICloudFilesCDNRequest.m
Expand Up @@ -81,15 +81,15 @@ + (id)listRequestWithLimit:(NSUInteger)limit marker:(NSString *)marker enabledOn
NSString *query = @"?format=xml";

if (limit > 0) {
query = [query stringByAppendingString:[NSString stringWithFormat:@"&limit=%i", limit]];
query = [query stringByAppendingString:[NSString stringWithFormat:@"&limit=%lu", (unsigned long)limit]];
}

if (marker) {
query = [query stringByAppendingString:[NSString stringWithFormat:@"&marker=%@", marker]];
}

if (limit > 0) {
query = [query stringByAppendingString:[NSString stringWithFormat:@"&limit=%i", limit]];
query = [query stringByAppendingString:[NSString stringWithFormat:@"&limit=%lu", (unsigned long)limit]];
}

ASICloudFilesCDNRequest *request = [ASICloudFilesCDNRequest cdnRequestWithMethod:@"GET" query:query];
Expand Down Expand Up @@ -128,7 +128,7 @@ + (id)putRequestWithContainer:(NSString *)containerName {

+ (id)putRequestWithContainer:(NSString *)containerName ttl:(NSUInteger)ttl {
ASICloudFilesCDNRequest *request = [ASICloudFilesCDNRequest cdnRequestWithMethod:@"PUT" containerName:containerName];
[request addRequestHeader:@"X-Ttl" value:[NSString stringWithFormat:@"%i", ttl]];
[request addRequestHeader:@"X-Ttl" value:[NSString stringWithFormat:@"%lu", (unsigned long)ttl]];
return request;
}

Expand All @@ -148,7 +148,7 @@ + (id)postRequestWithContainer:(NSString *)containerName {
+ (id)postRequestWithContainer:(NSString *)containerName cdnEnabled:(BOOL)cdnEnabled ttl:(NSUInteger)ttl {
ASICloudFilesCDNRequest *request = [ASICloudFilesCDNRequest cdnRequestWithMethod:@"POST" containerName:containerName];
if (ttl > 0) {
[request addRequestHeader:@"X-Ttl" value:[NSString stringWithFormat:@"%i", ttl]];
[request addRequestHeader:@"X-Ttl" value:[NSString stringWithFormat:@"%lu", (unsigned long)ttl]];
}
[request addRequestHeader:@"X-CDN-Enabled" value:cdnEnabled ? @"True" : @"False"];
return request;
Expand Down
2 changes: 1 addition & 1 deletion Classes/CloudFiles/ASICloudFilesContainerRequest.m
Expand Up @@ -64,7 +64,7 @@ + (id)listRequestWithLimit:(NSUInteger)limit marker:(NSString *)marker {
NSString *queryString = @"?format=xml";

if (limit > 0) {
queryString = [queryString stringByAppendingString:[NSString stringWithFormat:@"&limit=%i", limit]];
queryString = [queryString stringByAppendingString:[NSString stringWithFormat:@"&limit=%lu", (unsigned long)limit]];
}

if (marker != nil) {
Expand Down