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
00034 @implementation CPURLRequest : CPObject
00035 {
00036 CPURL _URL;
00037
00038
00039 CPString _HTTPBody;
00040 CPString _HTTPMethod;
00041 CPDictionary _HTTPHeaderFields;
00042 }
00043
00049 + (id)requestWithURL:(CPURL)aURL
00050 {
00051 return [[CPURLRequest alloc] initWithURL:aURL];
00052 }
00053
00059 - (id)initWithURL:(CPURL)aURL
00060 {
00061 self = [super init];
00062
00063 if (self)
00064 {
00065 [self setURL:aURL];
00066
00067 _HTTPBody = @"";
00068 _HTTPMethod = @"GET";
00069 _HTTPHeaderFields = [CPDictionary dictionary];
00070
00071 [self setValue:"Thu, 1 Jan 1970 00:00:00 GMT" forHTTPHeaderField:"If-Modified-Since"];
00072 [self setValue:"no-cache" forHTTPHeaderField:"Cache-Control"];
00073 [self setValue:"XMLHttpRequest" forHTTPHeaderField:"X-Requested-With"];
00074 }
00075
00076 return self;
00077 }
00078
00082 - (CPURL)URL
00083 {
00084 return _URL;
00085 }
00086
00091 - (void)setURL:(CPURL)aURL
00092 {
00093
00094 _URL = new CFURL(aURL);
00095 }
00096
00101 - (void)setHTTPBody:(CPString)anHTTPBody
00102 {
00103 _HTTPBody = anHTTPBody;
00104 }
00105
00109 - (CPString)HTTPBody
00110 {
00111 return _HTTPBody;
00112 }
00113
00118 - (void)setHTTPMethod:(CPString)anHTTPMethod
00119 {
00120 _HTTPMethod = anHTTPMethod;
00121 }
00122
00126 - (CPString)HTTPMethod
00127 {
00128 return _HTTPMethod;
00129 }
00130
00134 - (CPDictionary)allHTTPHeaderFields
00135 {
00136 return _HTTPHeaderFields;
00137 }
00138
00143 - (CPString)valueForHTTPHeaderField:(CPString)aField
00144 {
00145 return [_HTTPHeaderFields objectForKey:aField];
00146 }
00147
00153 - (void)setValue:(CPString)aValue forHTTPHeaderField:(CPString)aField
00154 {
00155 [_HTTPHeaderFields setObject:aValue forKey:aField];
00156 }
00157
00158 @end