@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2022 Jonathan Schleifer + * Copyright (c) 2008-2024 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 @@ -17,13 +17,13 @@ #import "OFSocket.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN -@class OFURI; +@class OFData; @class OFDictionary OF_GENERIC(KeyType, ObjectType); -@class OFData; +@class OFIRI; @class OFString; /** @file */ /** @@ -51,11 +51,11 @@ /** * @struct OFHTTPRequestProtocolVersion OFHTTPRequest.h ObjFW/OFHTTPRequest.h * * @brief The HTTP version of the HTTP request. */ -typedef struct OF_BOXABLE { +typedef struct OF_BOXABLE OFHTTPRequestProtocolVersion { /** The major of the HTTP version */ unsigned char major; /** The minor of the HTTP version */ unsigned char minor; } OFHTTPRequestProtocolVersion; @@ -66,22 +66,22 @@ * @brief A class for storing HTTP requests. */ OF_SUBCLASSING_RESTRICTED @interface OFHTTPRequest: OFObject { - OFURI *_URI; + OFIRI *_IRI; OFHTTPRequestMethod _method; OFHTTPRequestProtocolVersion _protocolVersion; OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers; OFSocketAddress _remoteAddress; bool _hasRemoteAddress; } /** - * @brief The URI of the HTTP request. + * @brief The IRI of the HTTP request. */ -@property (copy, nonatomic) OFURI *URI; +@property (copy, nonatomic) OFIRI *IRI; /** * @brief The protocol version of the HTTP request. * * @throw OFUnsupportedVersionException The specified version cannot be set @@ -116,38 +116,38 @@ * @note The setter creates a copy of the remote address. */ @property OF_NULLABLE_PROPERTY (nonatomic) const OFSocketAddress *remoteAddress; /** - * @brief Creates a new OFHTTPRequest with the specified URI. + * @brief Creates a new OFHTTPRequest with the specified IRI. * - * @param URI The URI for the request + * @param IRI The IRI for the request * @return A new, autoreleased OFHTTPRequest */ -+ (instancetype)requestWithURI: (OFURI *)URI; ++ (instancetype)requestWithIRI: (OFIRI *)IRI; /** - * @brief Initializes an already allocated OFHTTPRequest with the specified URI. + * @brief Initializes an already allocated OFHTTPRequest with the specified IRI. * - * @param URI The URI for the request + * @param IRI The IRI for the request * @return An initialized OFHTTPRequest */ -- (instancetype)initWithURI: (OFURI *)URI; +- (instancetype)initWithIRI: (OFIRI *)IRI; - (instancetype)init OF_UNAVAILABLE; @end #ifdef __cplusplus extern "C" { #endif /** - * @brief Returns a C string describing the specified request method. + * @brief Returns a string describing the specified request method. * - * @param method The request method which should be described as a C string - * @return A C string describing the specified request method + * @param method The request method which should be described as a string + * @return A string describing the specified request method */ -extern const char *_Nullable OFHTTPRequestMethodName( +extern OFString *_Nullable OFHTTPRequestMethodString( OFHTTPRequestMethod method); /** * @brief Returns the request method for the specified string. * @@ -154,11 +154,35 @@ * @param string The string for which the request method should be returned * @return The request method for the specified string * @throw OFInvalidFormatException The specified string is not a valid HTTP * request method */ -extern OFHTTPRequestMethod OFHTTPRequestMethodParseName(OFString *string); +extern OFHTTPRequestMethod OFHTTPRequestMethodParseString(OFString *string); + +/** + * @brief Returns a C string describing the specified request method. + * + * @deprecated Use @ref OFHTTPRequestMethodString instead. + * + * @param method The request method which should be described as a C string + * @return A C string describing the specified request method + */ +extern const char *_Nullable OFHTTPRequestMethodName(OFHTTPRequestMethod method) + OF_DEPRECATED(ObjFW, 1, 1, "Use OFHTTPRequestMethodString instead"); + +/** + * @brief Returns the request method for the specified string. + * + * @deprecated Use @ref OFHTTPRequestMethodParseString instead. + * + * @param string The string for which the request method should be returned + * @return The request method for the specified string + * @throw OFInvalidFormatException The specified string is not a valid HTTP + * request method + */ +extern OFHTTPRequestMethod OFHTTPRequestMethodParseName(OFString *string) + OF_DEPRECATED(ObjFW, 1, 1, "Use OFHTTPRequestMethodParseString instead"); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END