Index: src/OFDNSResolver.h ================================================================== --- src/OFDNSResolver.h +++ src/OFDNSResolver.h @@ -258,11 +258,11 @@ * @brief Synchronously resolves the specified host to socket addresses. * * @param host The host to resolve * @param addressFamily The desired socket address family * @return OFData containing several OFSocketAddress - * @throw OFInvalidServerReplyException The received response was invalid + * @throw OFInvalidServerResponseException The received response was invalid * @throw OFTruncatedDataException The received response was truncated */ - (OFData *)resolveAddressesForHost: (OFString *)host addressFamily: (OFSocketAddressFamily)addressFamily; Index: src/OFDNSResolver.m ================================================================== --- src/OFDNSResolver.m +++ src/OFDNSResolver.m @@ -36,11 +36,11 @@ #import "OFDNSQueryFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" -#import "OFInvalidServerReplyException.h" +#import "OFInvalidServerResponseException.h" #import "OFNotImplementedException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #ifndef SOCK_DNS @@ -126,21 +126,21 @@ if (componentLength & 0xC0) { size_t j; OFString *suffix; if (pointerLevel == 0) - @throw [OFInvalidServerReplyException + @throw [OFInvalidServerResponseException exception]; if (*i >= length) @throw [OFTruncatedDataException exception]; j = ((componentLength & 0x3F) << 8) | buffer[(*i)++]; if (j == *i - 2) /* Pointing to itself?! */ - @throw [OFInvalidServerReplyException + @throw [OFInvalidServerResponseException exception]; suffix = parseName(buffer, length, &j, pointerLevel - 1); @@ -173,11 +173,11 @@ { if (recordType == OFDNSRecordTypeA && DNSClass == OFDNSClassIN) { OFSocketAddress address; if (dataLength != 4) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPv4; address.length = sizeof(address.sockaddr.in); @@ -192,11 +192,11 @@ size_t j = i; OFString *authoritativeHost = parseName(buffer, length, &j, maxAllowedPointers); if (j != i + dataLength) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; return [[[OFNSDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass authoritativeHost: authoritativeHost @@ -205,11 +205,11 @@ size_t j = i; OFString *alias = parseName(buffer, length, &j, maxAllowedPointers); if (j != i + dataLength) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; return [[[OFCNAMEDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass alias: alias @@ -221,17 +221,17 @@ OFString *responsiblePerson; uint32_t serialNumber, refreshInterval, retryInterval; uint32_t expirationInterval, minTTL; if (j > i + dataLength) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; responsiblePerson = parseName(buffer, length, &j, maxAllowedPointers); if (dataLength - (j - i) != 20) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; serialNumber = (buffer[j] << 24) | (buffer[j + 1] << 16) | (buffer[j + 2] << 8) | buffer[j + 3]; refreshInterval = (buffer[j + 4] << 24) | (buffer[j + 5] << 16) | (buffer[j + 6] << 8) | @@ -259,11 +259,11 @@ size_t j = i; OFString *domainName = parseName(buffer, length, &j, maxAllowedPointers); if (j != i + dataLength) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; return [[[OFPTRDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass domainName: domainName @@ -272,16 +272,16 @@ size_t j = i; OFString *CPU = parseString(buffer, length, &j); OFString *OS; if (j > i + dataLength) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; OS = parseString(buffer, length, &j); if (j != i + dataLength) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; return [[[OFHINFODNSResourceRecord alloc] initWithName: name DNSClass: DNSClass CPU: CPU @@ -291,20 +291,20 @@ uint16_t preference; size_t j; OFString *mailExchange; if (dataLength < 2) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; preference = (buffer[i] << 8) | buffer[i + 1]; j = i + 2; mailExchange = parseName(buffer, length, &j, maxAllowedPointers); if (j != i + dataLength) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; return [[[OFMXDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass preference: preference @@ -316,11 +316,11 @@ while (dataLength > 0) { uint_fast8_t stringLength = buffer[i++]; dataLength--; if (stringLength > dataLength) - @throw [OFInvalidServerReplyException + @throw [OFInvalidServerResponseException exception]; [textStrings addObject: [OFData dataWithItems: buffer + i count: stringLength]]; @@ -341,17 +341,17 @@ OFString *mailbox = parseName(buffer, length, &j, maxAllowedPointers); OFString *TXTDomainName; if (j > i + dataLength) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; TXTDomainName = parseName(buffer, length, &j, maxAllowedPointers); if (j != i + dataLength) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; return [[[OFRPDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass mailbox: mailbox @@ -360,11 +360,11 @@ } else if (recordType == OFDNSRecordTypeAAAA && DNSClass == OFDNSClassIN) { OFSocketAddress address; if (dataLength != 16) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPv6; address.length = sizeof(address.sockaddr.in6); @@ -384,21 +384,21 @@ uint16_t priority, weight, port; size_t j; OFString *target; if (dataLength < 6) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; priority = (buffer[i] << 8) | buffer[i + 1]; weight = (buffer[i + 2] << 8) | buffer[i + 3]; port = (buffer[i + 4] << 8) | buffer[i + 5]; j = i + 6; target = parseName(buffer, length, &j, maxAllowedPointers); if (j != i + dataLength) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; return [[[OFSRVDNSResourceRecord alloc] initWithName: name priority: priority weight: weight @@ -935,15 +935,15 @@ queryDataBuffer = context->_queryData.items; /* QR */ if ((buffer[2] & 0x80) == 0) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; /* Opcode */ if ((buffer[2] & 0x78) != (queryDataBuffer[2] & 0x78)) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; /* TC */ if (buffer[2] & 0x02) { OFRunLoopMode runLoopMode; Index: src/OFData.m ================================================================== --- src/OFData.m +++ src/OFData.m @@ -33,11 +33,10 @@ #import "OFURLHandler.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" -#import "OFInvalidServerReplyException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedProtocolException.h" Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -36,11 +36,11 @@ #import "OFAlreadyConnectedException.h" #import "OFHTTPRequestFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" -#import "OFInvalidServerReplyException.h" +#import "OFInvalidServerResponseException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" @@ -455,21 +455,21 @@ return false; } if (![line hasPrefix: @"HTTP/"] || line.length < 9 || [line characterAtIndex: 8] != ' ') - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; _version = [[line substringWithRange: OFMakeRange(5, 3)] copy]; if (![_version isEqual: @"1.0"] && ![_version isEqual: @"1.1"]) @throw [OFUnsupportedVersionException exceptionWithVersion: _version]; status = [line substringWithRange: OFMakeRange(9, 3)].longLongValue; if (status < 0 || status > 599) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; _status = (short)status; return true; } @@ -479,11 +479,11 @@ OFString *key, *value, *old; const char *lineC, *tmp; char *keyC; if (line == nil) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; if (line.length == 0) { [_serverHeaders makeImmutable]; if ([_client->_delegate respondsToSelector: @selector(client: @@ -503,11 +503,11 @@ } lineC = line.UTF8String; if ((tmp = strchr(lineC, ':')) == NULL) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; keyC = OFAllocMemory(tmp - lineC + 1, 1); memcpy(keyC, lineC, tmp - lineC); keyC[tmp - lineC] = '\0'; normalizeKey(keyC); @@ -542,11 +542,12 @@ bool ret; if (exception != nil) { if ([exception isKindOfClass: [OFInvalidEncodingException class]]) - exception = [OFInvalidServerReplyException exception]; + exception = + [OFInvalidServerResponseException exception]; [self raiseException: exception]; return false; } @@ -899,11 +900,11 @@ isEqual: @"chunked"]; contentLength = [headers objectForKey: @"Content-Length"]; if (contentLength != nil) { if (_chunked || contentLength.length == 0) - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; _hasContentLength = true; @try { unsigned long long toRead = @@ -912,11 +913,11 @@ if (toRead > LLONG_MAX) @throw [OFOutOfRangeException exception]; _toRead = (long long)toRead; } @catch (OFInvalidFormatException *e) { - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; } } } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length @@ -958,16 +959,16 @@ switch ([_stream readIntoBuffer: tmp length: 2]) { case 2: _toRead++; if (tmp[1] != '\n') - @throw [OFInvalidServerReplyException + @throw [OFInvalidServerResponseException exception]; case 1: _toRead++; if (tmp[0] != '\r') - @throw [OFInvalidServerReplyException + @throw [OFInvalidServerResponseException exception]; } if (_setAtEndOfStream && _toRead == 0) _atEndOfStream = true; @@ -977,11 +978,11 @@ char tmp; if ([_stream readIntoBuffer: &tmp length: 1] == 1) { _toRead++; if (tmp != '\n') - @throw [OFInvalidServerReplyException + @throw [OFInvalidServerResponseException exception]; } if (_setAtEndOfStream && _toRead == 0) _atEndOfStream = true; @@ -1004,11 +1005,11 @@ size_t pos; @try { line = [_stream tryReadLine]; } @catch (OFInvalidEncodingException *e) { - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; } if (line == nil) return 0; @@ -1022,11 +1023,11 @@ * at end of stream. */ if (_stream.atEndOfStream && pos == OFNotFound) @throw [OFTruncatedDataException exception]; else - @throw [OFInvalidServerReplyException + @throw [OFInvalidServerResponseException exception]; } @try { unsigned long long toRead = @@ -1035,11 +1036,11 @@ if (toRead > LLONG_MAX) @throw [OFOutOfRangeException exception]; _toRead = (long long)toRead; } @catch (OFInvalidFormatException *e) { - @throw [OFInvalidServerReplyException exception]; + @throw [OFInvalidServerResponseException exception]; } if (_toRead == 0) { _setAtEndOfStream = true; _toRead = -2; Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -190,11 +190,11 @@ #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFInvalidJSONException.h" -#import "OFInvalidServerReplyException.h" +#import "OFInvalidServerResponseException.h" #import "OFLinkFailedException.h" #ifdef OF_HAVE_SOCKETS # import "OFListenFailedException.h" #endif #ifdef OF_HAVE_PLUGINS Index: src/exceptions/Makefile ================================================================== --- src/exceptions/Makefile +++ src/exceptions/Makefile @@ -17,11 +17,11 @@ OFInitializationFailedException.m \ OFInvalidArgumentException.m \ OFInvalidEncodingException.m \ OFInvalidFormatException.m \ OFInvalidJSONException.m \ - OFInvalidServerReplyException.m \ + OFInvalidServerResponseException.m \ OFLinkFailedException.m \ OFLockFailedException.m \ OFMalformedXMLException.m \ OFMoveItemFailedException.m \ OFNotImplementedException.m \ DELETED src/exceptions/OFInvalidServerReplyException.h Index: src/exceptions/OFInvalidServerReplyException.h ================================================================== --- src/exceptions/OFInvalidServerReplyException.h +++ src/exceptions/OFInvalidServerReplyException.h @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#import "OFException.h" - -OF_ASSUME_NONNULL_BEGIN - -/** - * @class OFInvalidServerReplyException \ - * OFInvalidServerReplyException.h ObjFW/OFInvalidServerReplyException.h - * - * @brief An exception indicating that the server sent an invalid reply. - */ -@interface OFInvalidServerReplyException: OFException -{ - OF_RESERVE_IVARS(OFInvalidServerReplyException, 4) -} -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFInvalidServerReplyException.m Index: src/exceptions/OFInvalidServerReplyException.m ================================================================== --- src/exceptions/OFInvalidServerReplyException.m +++ src/exceptions/OFInvalidServerReplyException.m @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#include "config.h" - -#import "OFInvalidServerReplyException.h" -#import "OFString.h" - -@implementation OFInvalidServerReplyException -- (OFString *)description -{ - return @"Got an invalid reply from the server!"; -} -@end ADDED src/exceptions/OFInvalidServerResponseException.h Index: src/exceptions/OFInvalidServerResponseException.h ================================================================== --- src/exceptions/OFInvalidServerResponseException.h +++ src/exceptions/OFInvalidServerResponseException.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFException.h" + +OF_ASSUME_NONNULL_BEGIN + +/** + * @class OFInvalidServerResponseException \ + * OFInvalidServerResponseException.h \ + * ObjFW/OFInvalidServerResponseException.h + * + * @brief An exception indicating that the server sent an invalid response. + */ +@interface OFInvalidServerResponseException: OFException +{ + OF_RESERVE_IVARS(OFInvalidServerResponseException, 4) +} +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFInvalidServerResponseException.m Index: src/exceptions/OFInvalidServerResponseException.m ================================================================== --- src/exceptions/OFInvalidServerResponseException.m +++ src/exceptions/OFInvalidServerResponseException.m @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "OFInvalidServerResponseException.h" +#import "OFString.h" + +@implementation OFInvalidServerResponseException +- (OFString *)description +{ + return @"Got an invalid response from the server!"; +} +@end Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -42,11 +42,11 @@ #import "OFConnectionFailedException.h" #import "OFHTTPRequestFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" -#import "OFInvalidServerReplyException.h" +#import "OFInvalidServerResponseException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFResolveHostFailedException.h" #import "OFRetrieveItemAttributesFailedException.h" @@ -832,18 +832,18 @@ @" Connection failed: %[exception]", @"prog", [OFApplication programName], @"url", request.URL.string, @"exception", exception)]; } else if ([exception isKindOfClass: - [OFInvalidServerReplyException class]]) { + [OFInvalidServerResponseException class]]) { if (!_quiet) [OFStdOut writeString: @"\n"]; [OFStdErr writeLine: OF_LOCALIZED( - @"download_failed_invalid_server_reply", + @"download_failed_invalid_server_response", @"%[prog]: Failed to download <%[url]>!\n" - @" Invalid server reply!", + @" Invalid server response!", @"prog", [OFApplication programName], @"url", request.URL.string)]; } else if ([exception isKindOfClass: [OFUnsupportedProtocolException class]]) { if (!_quiet) Index: utils/ofhttp/lang/de.json ================================================================== --- utils/ofhttp/lang/de.json +++ utils/ofhttp/lang/de.json @@ -46,11 +46,11 @@ ], "download_failed_connection_failed": [ "%[prog]: Fehler beim Download von <%[url]>!\n", " Verbindung fehlgeschlagen: %[exception]" ], - "download_failed_invalid_server_reply": [ + "download_failed_invalid_server_response": [ "%[prog]: Fehler beim Download von <%[url]>!\n", " Ungültige Antwort vom Server!" ], "no_tls_support": [ "%[prog]: Keine TLS-Unterstützung in ObjFW!\n",