00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 @import "CPObject.j"
00024
00025
00032 @implementation CPURLRequest : CPObject
00033 {
00034 CPURL _URL;
00035
00036
00037 CPString _HTTPBody;
00038 CPString _HTTPMethod;
00039 CPDictionary _HTTPHeaderFields;
00040 }
00041
00047 + (id)requestWithURL:(CPURL)aURL
00048 {
00049 return [[CPURLRequest alloc] initWithURL:aURL];
00050 }
00051
00057 - (id)initWithURL:(CPURL)aURL
00058 {
00059 self = [super init];
00060
00061 if (self)
00062 {
00063 _URL = aURL;
00064 _HTTPBody = @"";
00065 _HTTPMethod = @"GET";
00066 _HTTPHeaderFields = [CPDictionary dictionary];
00067
00068 [self setValue:"Thu, 1 Jan 1970 00:00:00 GMT" forHTTPHeaderField:"If-Modified-Since"];
00069 [self setValue:"no-cache" forHTTPHeaderField:"Cache-Control"];
00070 [self setValue:"XMLHttpRequest" forHTTPHeaderField:"X-Requested-With"];
00071 }
00072
00073 return self;
00074 }
00075
00079 - (CPURL)URL
00080 {
00081 return _URL;
00082 }
00083
00088 - (void)setURL:(CPURL)aURL
00089 {
00090 _URL = aURL;
00091 }
00092
00097 - (void)setHTTPBody:(CPString)anHTTPBody
00098 {
00099 _HTTPBody = anHTTPBody;
00100 }
00101
00105 - (CPString)HTTPBody
00106 {
00107 return _HTTPBody;
00108 }
00109
00114 - (void)setHTTPMethod:(CPString)anHTTPMethod
00115 {
00116 _HTTPMethod = anHTTPMethod;
00117 }
00118
00122 - (CPString)HTTPMethod
00123 {
00124 return _HTTPMethod;
00125 }
00126
00130 - (CPDictionary)allHTTPHeaderFields
00131 {
00132 return _HTTPHeaderFields;
00133 }
00134
00139 - (CPString)valueForHTTPHeaderField:(CPString)aField
00140 {
00141 return [_HTTPHeaderFields objectForKey:aField];
00142 }
00143
00149 - (void)setValue:(CPString)aValue forHTTPHeaderField:(CPString)aField
00150 {
00151 [_HTTPHeaderFields setObject:aValue forKey:aField];
00152 }
00153
00154 @end