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
00030 @implementation CPURLRequest : CPObject
00031 {
00032 CPURL _URL;
00033
00034
00035 CPString _HTTPBody;
00036 CPString _HTTPMethod;
00037 CPDictionary _HTTPHeaderFields;
00038 }
00039
00045 + (id)requestWithURL:(CPURL)aURL
00046 {
00047 return [[CPURLRequest alloc] initWithURL:aURL];
00048 }
00049
00055 - (id)initWithURL:(CPURL)aURL
00056 {
00057 self = [super init];
00058
00059 if (self)
00060 {
00061 _URL = aURL;
00062 _HTTPBody = @"";
00063 _HTTPMethod = @"GET";
00064 _HTTPHeaderFields = [CPDictionary dictionary];
00065
00066 [self setValue:"Thu, 1 Jan 1970 00:00:00 GMT" forHTTPHeaderField:"If-Modified-Since"];
00067 [self setValue:"no-cache" forHTTPHeaderField:"Cache-Control"];
00068 }
00069
00070 return self;
00071 }
00072
00076 - (CPURL)URL
00077 {
00078 return _URL;
00079 }
00080
00085 - (void)setURL:(CPURL)aURL
00086 {
00087 _URL = aURL;
00088 }
00089
00094 - (void)setHTTPBody:(CPString)anHTTPBody
00095 {
00096 _HTTPBody = anHTTPBody;
00097 }
00098
00102 - (CPString)HTTPBody
00103 {
00104 return _HTTPBody;
00105 }
00106
00111 - (void)setHTTPMethod:(CPString)anHTTPMethod
00112 {
00113 _HTTPMethod = anHTTPMethod;
00114 }
00115
00119 - (CPString)HTTPMethod
00120 {
00121 return _HTTPMethod;
00122 }
00123
00127 - (CPDictionary)allHTTPHeaderFields
00128 {
00129 return _HTTPHeaderFields;
00130 }
00131
00136 - (CPString)valueForHTTPHeaderField:(CPString)aField
00137 {
00138 return [_HTTPHeaderFields objectForKey:aField];
00139 }
00140
00146 - (void)setValue:(CPString)aValue forHTTPHeaderField:(CPString)aField
00147 {
00148 [_HTTPHeaderFields setObject:aValue forKey:aField];
00149 }
00150
00151 @end