Differences From Artifact [1abecd6ce8]:
- File src/OFHTTPResponse.m — part of check-in [3356b9940c] at 2020-04-19 10:02:51 on branch trunk — Clean up which exception is used when a little (user: js, size: 8119) [annotate] [blame] [check-ins using] [more...]
To Artifact [b38122cc28]:
- File
src/OFHTTPResponse.m
— part of check-in
[b6ee372b98]
at
2020-08-11 19:45:36
on branch trunk
— OFString: Rework number parsing API
This solves the old signed vs. unsigned problem and allows for more
bases than just 8, 10 and 16, as well as auto-detection of the base (if
base is 0). (user: js, size: 8310) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
267 268 269 270 271 272 273 | return _protocolVersion; } - (void)setProtocolVersionString: (OFString *)string { void *pool = objc_autoreleasePoolPush(); OFArray *components = [string componentsSeparatedByString: @"."]; | | | | | | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | return _protocolVersion; } - (void)setProtocolVersionString: (OFString *)string { void *pool = objc_autoreleasePoolPush(); OFArray *components = [string componentsSeparatedByString: @"."]; unsigned long long major, minor; of_http_request_protocol_version_t protocolVersion; if (components.count != 2) @throw [OFInvalidFormatException exception]; major = [components.firstObject unsignedLongLongValue]; minor = [components.lastObject unsignedLongLongValue]; if (major > UINT8_MAX || minor > UINT8_MAX) @throw [OFOutOfRangeException exception]; protocolVersion.major = (uint8_t)major; protocolVersion.minor = (uint8_t)minor; self.protocolVersion = protocolVersion; |
︙ | ︙ | |||
302 303 304 305 306 307 308 | { return [self stringWithEncoding: OF_STRING_ENCODING_AUTODETECT]; } - (OFString *)stringWithEncoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); | | | > > > > > > > | > | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | { return [self stringWithEncoding: OF_STRING_ENCODING_AUTODETECT]; } - (OFString *)stringWithEncoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); OFString *contentType, *contentLengthString, *ret; OFData *data; if (encoding == OF_STRING_ENCODING_AUTODETECT && (contentType = [_headers objectForKey: @"Content-Type"]) != nil) encoding = encodingForContentType(contentType); if (encoding == OF_STRING_ENCODING_AUTODETECT) encoding = OF_STRING_ENCODING_UTF_8; data = [self readDataUntilEndOfStream]; contentLengthString = [_headers objectForKey: @"Content-Length"]; if (contentLengthString != nil) { unsigned long long contentLength = contentLengthString.unsignedLongLongValue; if (contentLength > SIZE_MAX) @throw [OFOutOfRangeException exception]; if (data.count != (size_t)contentLength) @throw [OFTruncatedDataException exception]; } ret = [[OFString alloc] initWithCString: (char *)data.items encoding: encoding length: data.count]; objc_autoreleasePoolPop(pool); |
︙ | ︙ |