@@ -374,11 +374,11 @@ pos = [line rangeOfString: @" "].location; if (pos == OF_NOT_FOUND) return [self sendErrorAndClose: 400]; - method = [line substringWithRange: of_range(0, pos)]; + method = [line substringToIndex: pos]; @try { _method = of_http_request_method_from_string(method); } @catch (OFInvalidArgumentException *e) { return [self sendErrorAndClose: 405]; } @@ -450,13 +450,12 @@ pos = [line rangeOfString: @":"].location; if (pos == OF_NOT_FOUND) return [self sendErrorAndClose: 400]; - key = [line substringWithRange: of_range(0, pos)]; - value = [line substringWithRange: - of_range(pos + 1, line.length - pos - 1)]; + key = [line substringToIndex: pos]; + value = [line substringFromIndex: pos + 1]; key = normalizedKey(key.stringByDeletingTrailingWhitespaces); value = value.stringByDeletingLeadingWhitespaces; old = [_headers objectForKey: key]; @@ -471,18 +470,15 @@ rangeOfString: @":" options: OF_STRING_SEARCH_BACKWARDS].location; if (pos != OF_NOT_FOUND) { [_host release]; - _host = [[value substringWithRange: - of_range(0, pos)] retain]; + _host = [[value substringToIndex: pos] retain]; @try { - of_range_t range = - of_range(pos + 1, value.length - pos - 1); unsigned long long portTmp = - [value substringWithRange: range] + [value substringFromIndex: pos + 1] .unsignedLongLongValue; if (portTmp < 1 || portTmp > UINT16_MAX) return [self sendErrorAndClose: 400]; @@ -546,13 +542,12 @@ URL.port = [OFNumber numberWithUnsignedShort: _port]; if ((pos = [_path rangeOfString: @"?"].location) != OF_NOT_FOUND) { OFString *path, *query; - path = [_path substringWithRange: of_range(0, pos)]; - query = [_path substringWithRange: - of_range(pos + 1, _path.length - pos - 1)]; + path = [_path substringToIndex: pos]; + query = [_path substringFromIndex: pos + 1]; URL.URLEncodedPath = path; URL.URLEncodedQuery = query; } else URL.URLEncodedPath = _path; @@ -696,11 +691,11 @@ return length; } else { void *pool = objc_autoreleasePoolPush(); OFString *line; - of_range_t range; + size_t pos; unsigned long long toRead; @try { line = [_socket tryReadLine]; } @catch (OFInvalidEncodingException *e) { @@ -708,22 +703,20 @@ } if (line == nil) return 0; - range = [line rangeOfString: @";"]; - if (range.location != OF_NOT_FOUND) - line = [line substringWithRange: - of_range(0, range.location)]; + pos = [line rangeOfString: @";"].location; + if (pos != OF_NOT_FOUND) + line = [line substringToIndex: pos]; if (line.length < 1) { /* * We have read the empty string because the socket is * at end of stream. */ - if (_socket.atEndOfStream && - range.location == OF_NOT_FOUND) + if (_socket.atEndOfStream && pos == OF_NOT_FOUND) @throw [OFTruncatedDataException exception]; else @throw [OFInvalidFormatException exception]; }