137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
- (id)copy
{
OFHTTPRequest *copy = [[OFHTTPRequest alloc] init];
@try {
copy->_method = _method;
copy->_protocolVersion = _protocolVersion;
[copy setURL: _URL];
[copy setHeaders: _headers];
[copy setRemoteAddress: &_remoteAddress];
} @catch (id e) {
[copy release];
@throw e;
}
return copy;
}
|
|
|
|
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
- (id)copy
{
OFHTTPRequest *copy = [[OFHTTPRequest alloc] init];
@try {
copy->_method = _method;
copy->_protocolVersion = _protocolVersion;
copy.URL = _URL;
copy.headers = _headers;
copy.remoteAddress = &_remoteAddress;
} @catch (id e) {
[copy release];
@throw e;
}
return copy;
}
|
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
uint32_t hash;
OF_HASH_INIT(hash);
OF_HASH_ADD(hash, _method);
OF_HASH_ADD(hash, _protocolVersion.major);
OF_HASH_ADD(hash, _protocolVersion.minor);
OF_HASH_ADD_HASH(hash, [_URL hash]);
OF_HASH_ADD_HASH(hash, [_headers hash]);
OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_remoteAddress));
OF_HASH_FINALIZE(hash);
return hash;
}
|
|
|
|
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
uint32_t hash;
OF_HASH_INIT(hash);
OF_HASH_ADD(hash, _method);
OF_HASH_ADD(hash, _protocolVersion.major);
OF_HASH_ADD(hash, _protocolVersion.minor);
OF_HASH_ADD_HASH(hash, _URL.hash);
OF_HASH_ADD_HASH(hash, _headers.hash);
OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_remoteAddress));
OF_HASH_FINALIZE(hash);
return hash;
}
|
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
- (void)setProtocolVersionString: (OFString *)string
{
void *pool = objc_autoreleasePoolPush();
OFArray *components = [string componentsSeparatedByString: @"."];
intmax_t major, minor;
of_http_request_protocol_version_t protocolVersion;
if ([components count] != 2)
@throw [OFInvalidFormatException exception];
major = [[components firstObject] decimalValue];
minor = [[components lastObject] decimalValue];
if (major < 0 || major > UINT8_MAX || minor < 0 || minor > UINT8_MAX)
@throw [OFOutOfRangeException exception];
protocolVersion.major = (uint8_t)major;
protocolVersion.minor = (uint8_t)minor;
[self setProtocolVersion: protocolVersion];
objc_autoreleasePoolPop(pool);
}
- (OFString *)protocolVersionString
{
return [OFString stringWithFormat: @"%u.%u",
_protocolVersion.major,
_protocolVersion.minor];
}
- (OFString *)description
{
void *pool = objc_autoreleasePoolPush();
const char *method = of_http_request_method_to_string(_method);
OFString *indentedHeaders, *ret;
indentedHeaders = [[_headers description]
stringByReplacingOccurrencesOfString: @"\n"
withString: @"\n\t"];
ret = [[OFString alloc] initWithFormat:
@"<%@:\n\tURL = %@\n"
@"\tMethod = %s\n"
@"\tHeaders = %@\n"
@"\tRemote address = %@\n"
@">",
[self class], _URL, method, indentedHeaders,
of_socket_address_ip_string(&_remoteAddress, NULL)];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
@end
|
|
|
|
|
|
|
|
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
- (void)setProtocolVersionString: (OFString *)string
{
void *pool = objc_autoreleasePoolPush();
OFArray *components = [string componentsSeparatedByString: @"."];
intmax_t major, minor;
of_http_request_protocol_version_t protocolVersion;
if (components.count != 2)
@throw [OFInvalidFormatException exception];
major = [components.firstObject decimalValue];
minor = [components.lastObject decimalValue];
if (major < 0 || major > UINT8_MAX || minor < 0 || minor > UINT8_MAX)
@throw [OFOutOfRangeException exception];
protocolVersion.major = (uint8_t)major;
protocolVersion.minor = (uint8_t)minor;
self.protocolVersion = protocolVersion;
objc_autoreleasePoolPop(pool);
}
- (OFString *)protocolVersionString
{
return [OFString stringWithFormat: @"%u.%u",
_protocolVersion.major,
_protocolVersion.minor];
}
- (OFString *)description
{
void *pool = objc_autoreleasePoolPush();
const char *method = of_http_request_method_to_string(_method);
OFString *indentedHeaders, *ret;
indentedHeaders = [_headers.description
stringByReplacingOccurrencesOfString: @"\n"
withString: @"\n\t"];
ret = [[OFString alloc] initWithFormat:
@"<%@:\n\tURL = %@\n"
@"\tMethod = %s\n"
@"\tHeaders = %@\n"
@"\tRemote address = %@\n"
@">",
self.class, _URL, method, indentedHeaders,
of_socket_address_ip_string(&_remoteAddress, NULL)];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
@end
|