//
// ASIHTTPRequest.h
//
// Created by Ben Copsey on 04/10/2007.
// Copyright 2007-2011 All-Seeing Interactive. All rights reserved.
//
// A guide to the main features is available at:
// http://allseeing-i.com/ASIHTTPRequest
//
// Portions are based on the ImageClient example from Apple:
// See: http://developer.apple.com/samplecode/ImageClient/listing37.html
#import <Foundation/Foundation.h>
#if TARGET_OS_IPHONE
#import <CFNetwork/CFNetwork.h>
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
#import <UIKit/UIKit.h> // Necessary for background task support
#endif
#endif
#import <stdio.h>
#import "ASIHTTPRequestConfig.h"
#import "ASIHTTPRequestDelegate.h"
#import "ASIProgressDelegate.h"
#import "ASICacheDelegate.h"
@class ASIDataDecompressor;
extern NSString *ASIHTTPRequestVersion;
// Make targeting different platforms more reliable
// See: http://www.blumtnwerx.com/blog/2009/06/cross-sdk-code-hygiene-in-xcode/
#ifndef __IPHONE_3_2
#define __IPHONE_3_2 30200
#endif
#ifndef __IPHONE_4_0
#define __IPHONE_4_0 40000
#endif
#ifndef __MAC_10_5
#define __MAC_10_5 1050
#endif
#ifndef __MAC_10_6
#define __MAC_10_6 1060
#endif
typedef enum _ASIAuthenticationState {
ASINoAuthenticationNeededYet = 0,
ASIHTTPAuthenticationNeeded = 1,
ASIProxyAuthenticationNeeded = 2
} ASIAuthenticationState;
typedef enum _ASINetworkErrorType {
ASIConnectionFailureErrorType = 1,
ASIRequestTimedOutErrorType = 2,
ASIAuthenticationErrorType = 3,
ASIRequestCancelledErrorType = 4,
ASIUnableToCreateRequestErrorType = 5,
ASIInternalErrorWhileBuildingRequestType = 6,
ASIInternalErrorWhileApplyingCredentialsType = 7,
ASIFileManagementError = 8,
ASITooMuchRedirectionErrorType = 9,
ASIUnhandledExceptionError = 10,
ASICompressionError = 11
} ASINetworkErrorType;
// The error domain that all errors generated by ASIHTTPRequest use
extern NSString* const NetworkRequestErrorDomain;
// You can use this number to throttle upload and download bandwidth in iPhone OS apps send or receive a large amount of data
// This may help apps that might otherwise be rejected for inclusion into the app store for using excessive bandwidth
// This number is not official, as far as I know there is no officially documented bandwidth limit
extern unsigned long const ASIWWANBandwidthThrottleAmount;
#if NS_BLOCKS_AVAILABLE
typedef void (^ASIBasicBlock)(void);
typedef void (^ASIHeadersBlock)(NSDictionary *responseHeaders);
typedef void (^ASISizeBlock)(long long size);
typedef void (^ASIProgressBlock)(unsigned long long size, unsigned long long total);
typedef void (^ASIDataBlock)(NSData *data);
#endif
@interface ASIHTTPRequest : NSOperation <NSCopying> {
// The url for this operation, should include GET params in the query string where appropriate
NSURL *url;
// Will always contain the original url used for making the request (the value of url can change when a request is redirected)
NSURL *originalURL;
// Temporarily stores the url we are about to redirect to. Will be nil again when we do redirect
NSURL *redirectURL;
// The delegate - will be notified of various changes in state via the ASIHTTPRequestDelegate protocol
id <ASIHTTPRequestDelegate> delegate;
// Another delegate that is also notified of request status changes and progress updates
// Generally, you won't use this directly, but ASINetworkQueue sets itself as the queue so it can proxy updates to its own delegates
// NOTE: WILL BE RETAINED BY THE REQUEST
id <ASIHTTPRequestDelegate, ASIProgressDelegate> queue;
// HTTP method to use (eg: GET / POST / PUT / DELETE / HEAD etc). Defaults to GET
NSString *requestMethod;
// Request body - only used when the whole body is stored in memory (shouldStreamPostDataFromDisk is false)
NSMutableData *postBody;
// gzipped request body used when shouldCompressRequestBody is YES
NSData *compressedPostBody;
// When true, post body will be streamed from a file on disk, rather than loaded into memory at once (useful for large uploads)
// Automatically set to true in ASIFormDataRequests when using setFile:forKey:
BOOL shouldStreamPostDataFromDisk;
// Path to file used to store post body (when shouldStreamPostDataFromDisk is true)
// You can set this yourself - useful if you want to PUT a file from local disk
NSString *postBodyFilePath;
// Path to a temporary file used to store a deflated post body (when shouldCompressPostBody is YES)
NSString *compressedPostBodyFilePath;
// Set to true when ASIHTTPRequest automatically created a temporary file containing the request body (when true, the file at postBodyFilePath will be deleted at the end of the request)
BOOL didCreateTemporaryPostDataFile;
// Used when writing to the post body when shouldStreamPostDataFromDisk is true (via appendPostData: or appendPostDataFromFile:)
NSOutputStream *postBodyWriteStream;
// Used for reading from the post body when sending the request
NSInputStream *postBodyReadStream;
// Dictionary for custom HTTP request headers
NSMutableDictionary *requestHeaders;
// Set to YES when the request header dictionary has been populated, used to prevent this happening more than once
BOOL haveBuiltRequestHeaders;
// Will be populated with HTTP response headers from the server
NSDictionary *responseHeaders;
// Can be used to manually insert cookie headers to a request, but it's more likely that sessionCookies will do this for you
NSMutableArray *requestCookies;
// Will be populated with cookies
NSArray *responseCookies;
// If use useCookiePersistence is true, network requests will present valid cookies from previous requests
BOOL useCookiePersistence;
// If useKeychainPersistence is true, network requests will attempt to read credentials from the keychain, and will save them in the keychain when they are successfully presented
BOOL useKeychainPersistence;
// If useSessionPersistence is true, network requests will save credentials and reuse for the duration of the session (until clearSession is called)
BOOL useSessionPersistence;
// If allowCompressedResponse is true, requests will inform the server they can accept compressed data, and will automatically decompress gzipped responses. Default is true.
BOOL allowCompressedResponse;
// If shouldCompressRequestBody is true, the request body will be gzipped. Default is false.
// You will probably need to enable this feature on your webserver to make this work. Tested with apache only.
BOOL shouldCompressRequestBody;
// When downloadDestinationPath is set, the result of this request will be downloaded to the file at this location
// If downloadDestinationPath is not set, download data will be stored in memory
NSString *downloadDestinationPath;
// The location that files will be downloaded to. Once a download is complete, files will be decompressed (if necessary) and moved to downloadDestinationPath
NSString *temporaryFileDownloadPath;
// If the response is gzipped and shouldWaitToInflateCompressedResponses is NO, a file will be created at this path containing the inflated response as it comes in
NSString *temporaryUncompressedDataDownloadPath;
// Used for writing data to a file when downloadDestinationPath is set
NSOutputStream *fileDownloadOutputStream;
NSOutputStream *inflatedFileDownloadOutputStream;
// When the request fails or completes successfully, complete will be true
BOOL complete;
// external "finished" indicator, subject of KVO notifications; updates after 'complete'
BOOL finished;
// True if our 'cancel' selector has been called
BOOL cancelled;
// If an error occurs, error will contain an NSError
// If error code is = ASIConnectionFailureErrorType (1, Connection failure occurred) - inspect [[error userInfo] objectForKey:NSUnderlyingErrorKey] for more information
NSError *error;
// Username and password used for authentication
NSString *username;
NSString *password;
// User-Agent for this
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ASIHttpTest.zip (72个子文件)
ASIHttpTest
ASIHttpTest-Info.plist 909B
.DS_Store 6KB
Classes
.DS_Store 6KB
ASIHttpTestViewController.h 323B
ASIHttpTestAppDelegate.m 3KB
ASIHttpTestViewController.m 4KB
ASIHttp
Reachability
Reachability.h 7KB
Reachability.m 23KB
ASIHttpRequest
ASINetworkQueue.m 11KB
ASIHTTPRequestDelegate.h 2KB
ASIWebPageRequest
ASIWebPageRequest.h 4KB
ASIWebPageRequest.m 31KB
CloudFiles
ASICloudFilesContainerRequest.h 1KB
ASICloudFilesCDNRequest.h 2KB
ASICloudFilesContainer.m 568B
ASICloudFilesRequest.m 4KB
ASICloudFilesContainer.h 833B
ASICloudFilesContainerXMLParserDelegate.h 774B
ASICloudFilesObject.h 600B
ASICloudFilesObjectRequest.m 10KB
ASICloudFilesRequest.h 1KB
ASICloudFilesContainerXMLParserDelegate.m 3KB
ASICloudFilesCDNRequest.m 5KB
ASICloudFilesObjectRequest.h 3KB
ASICloudFilesObject.m 485B
ASICloudFilesContainerRequest.m 4KB
S3
ASIS3Request.m 10KB
ASIS3BucketObject.h 2KB
ASIS3ServiceRequest.h 805B
ASIS3BucketRequest.m 6KB
ASIS3Bucket.m 886B
ASINSXMLParserCompat.h 867B
ASIS3Bucket.h 972B
ASIS3BucketObject.m 2KB
ASIS3ServiceRequest.m 3KB
ASIS3BucketRequest.h 3KB
ASIS3ObjectRequest.m 5KB
ASIS3ObjectRequest.h 4KB
ASIS3Request.h 4KB
ASIHTTPRequest.m 180KB
ASICacheDelegate.h 5KB
ASIInputStream.m 3KB
ASIAuthenticationDialog.h 1KB
ASIDataDecompressor.m 6KB
ASIDownloadCache.h 2KB
ASIDataCompressor.h 2KB
ASIFormDataRequest.m 11KB
ASIFormDataRequest.h 3KB
ASIProgressDelegate.h 2KB
ASIHTTPRequestConfig.h 1KB
ASIDataCompressor.m 7KB
ASIInputStream.h 969B
ASIAuthenticationDialog.m 16KB
ASINetworkQueue.h 5KB
ASIDownloadCache.m 17KB
ASIHTTPRequest.h 44KB
ASIDataDecompressor.h 2KB
ASIHttpTestAppDelegate.h 494B
ASIHttpTest.xcodeproj
project.xcworkspace
contents.xcworkspacedata 156B
xcuserdata
apple.xcuserdatad
UserInterfaceState.xcuserstate 12KB
zhangnan.xcuserdatad
UserInterfaceState.xcuserstate 8KB
wxg.mode1v3 40KB
xcuserdata
apple.xcuserdatad
xcschemes
xcschememanagement.plist 483B
ASIHttpTest.xcscheme 3KB
zhangnan.xcuserdatad
xcschemes
xcschememanagement.plist 483B
ASIHttpTest.xcscheme 3KB
project.pbxproj 32KB
wxg.pbxuser 7KB
main.m 356B
ASIHttpTestViewController.xib 7KB
MainWindow.xib 20KB
ASIHttpTest_Prefix.pch 191B
共 72 条
- 1
资源评论
- Y-v-Y2014-11-11还可以,只是Xcode 6 arc 环境要去掉内存管理
- 北川谦一2014-08-26适合新手学习的资料
- thf6052509482014-11-04蛮不错 谢谢分享
- skhhh2014-06-17我是新手,看不懂,留着以后学习
- avel__2015-01-28没有看懂,先学习简单的以后在看
小村牛郎
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功