Differences From Artifact [2083545dd2]:
- File
src/OFHTTPRequest.m
— part of check-in
[44f45c2e35]
at
2017-01-09 17:36:36
on branch trunk
— Update copyright
Forgot to add 2017, even though I already did quite some changes in
2017. (user: js, size: 6720) [annotate] [blame] [check-ins using]
To Artifact [c7f95080da]:
- File
src/OFHTTPRequest.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 6728) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
25 26 27 28 29 30 31 | #import "OFDataArray.h" #import "OFArray.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnsupportedVersionException.h" | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #import "OFDataArray.h" #import "OFArray.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnsupportedVersionException.h" const char * of_http_request_method_to_string(of_http_request_method_t method) { switch (method) { case OF_HTTP_REQUEST_METHOD_OPTIONS: return "OPTIONS"; case OF_HTTP_REQUEST_METHOD_GET: return "GET"; |
︙ | ︙ | |||
82 83 84 85 86 87 88 | @synthesize cookies = _cookies, body = _body, remoteAddress = _remoteAddress; + (instancetype)request { return [[[self alloc] init] autorelease]; } | | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | @synthesize cookies = _cookies, body = _body, remoteAddress = _remoteAddress; + (instancetype)request { return [[[self alloc] init] autorelease]; } + (instancetype)requestWithURL: (OFURL *)URL { return [[[self alloc] initWithURL: URL] autorelease]; } - init { self = [super init]; _method = OF_HTTP_REQUEST_METHOD_GET; _protocolVersion.major = 1; _protocolVersion.minor = 1; return self; } - initWithURL: (OFURL *)URL { self = [self init]; @try { [self setURL: URL]; } @catch (id e) { [self release]; |
︙ | ︙ | |||
198 199 200 201 202 203 204 | } - (of_http_request_protocol_version_t)protocolVersion { return _protocolVersion; } | | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | } - (of_http_request_protocol_version_t)protocolVersion { return _protocolVersion; } - (void)setProtocolVersionFromString: (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) |
︙ | ︙ | |||
222 223 224 225 226 227 228 | protocolVersion.minor = (uint8_t)minor; [self setProtocolVersion: protocolVersion]; objc_autoreleasePoolPop(pool); } | | | | | | 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 | protocolVersion.minor = (uint8_t)minor; [self setProtocolVersion: protocolVersion]; objc_autoreleasePoolPop(pool); } - (OFString *)protocolVersionString { return [OFString stringWithFormat: @"%u.%u", _protocolVersion.major, _protocolVersion.minor]; } - (void)setBodyFromString: (OFString *)string { [self setBodyFromString: string encoding: OF_STRING_ENCODING_UTF_8]; } - (void)setBodyFromString: (OFString *)string encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); OFDataArray *body = [OFDataArray dataArray]; [body addItems: [string cStringWithEncoding: encoding] count: [string cStringLengthWithEncoding: encoding]]; [self setBody: body]; objc_autoreleasePoolPop(pool); } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); const char *method = of_http_request_method_to_string(_method); OFString *indentedHeaders, *indentedBody, *ret; indentedHeaders = [[_headers description] stringByReplacingOccurrencesOfString: @"\n" |
︙ | ︙ |