ObjFW
OFHTTPRequest.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License version 3.0 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * version 3.0 for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 3.0 along with this program. If not, see
17  * <https://www.gnu.org/licenses/>.
18  */
19 
20 #import "OFObject.h"
21 #import "OFSocket.h"
22 #import "OFString.h"
23 
24 OF_ASSUME_NONNULL_BEGIN
25 
26 @class OFData;
27 @class OFDictionary OF_GENERIC(KeyType, ObjectType);
28 @class OFIRI;
29 @class OFString;
30 
36 typedef enum {
54 
60 typedef struct OF_BOXABLE OFHTTPRequestProtocolVersion {
62  unsigned char major;
64  unsigned char minor;
66 
72 OF_SUBCLASSING_RESTRICTED
74 {
75  OFIRI *_IRI;
76  OFHTTPRequestMethod _method;
77  OFHTTPRequestProtocolVersion _protocolVersion;
78  OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers;
79  OFSocketAddress _remoteAddress;
80  bool _hasRemoteAddress;
81 }
82 
86 @property (copy, nonatomic) OFIRI *IRI;
87 
94 @property (nonatomic) OFHTTPRequestProtocolVersion protocolVersion;
95 
104 @property (copy, nonatomic) OFString *protocolVersionString;
109 @property (nonatomic) OFHTTPRequestMethod method;
114 @property OF_NULLABLE_PROPERTY (copy, nonatomic)
115  OFDictionary OF_GENERIC(OFString *, OFString *) *headers;
122 @property OF_NULLABLE_PROPERTY (nonatomic) const OFSocketAddress *remoteAddress;
130 + (instancetype)requestWithIRI: (OFIRI *)IRI;
131 
138 - (instancetype)initWithIRI: (OFIRI *)IRI;
139 
140 - (instancetype)init OF_UNAVAILABLE;
141 @end
142 
143 #ifdef __cplusplus
144 extern "C" {
145 #endif
146 
152 extern OFString *_Nullable OFHTTPRequestMethodString(
153  OFHTTPRequestMethod method);
154 
164 
173 extern const char *_Nullable OFHTTPRequestMethodName(OFHTTPRequestMethod method)
174  OF_DEPRECATED(ObjFW, 1, 1, "Use OFHTTPRequestMethodString instead");
175 
187  OF_DEPRECATED(ObjFW, 1, 1, "Use OFHTTPRequestMethodParseString instead");
188 #ifdef __cplusplus
189 }
190 #endif
191 
192 OF_ASSUME_NONNULL_END
unsigned char minor
Definition: OFHTTPRequest.h:64
The root class for all other classes inside ObjFW.
Definition: OFObject.h:690
Definition: OFHTTPRequest.h:40
OFHTTPRequestMethod OFHTTPRequestMethodParseName(OFString *string)
Returns the request method for the specified string.
Definition: OFHTTPRequest.m:93
OFString * OFHTTPRequestMethodString(OFHTTPRequestMethod method)
Returns a string describing the specified request method.
Definition: OFHTTPRequest.m:37
unsigned char major
Definition: OFHTTPRequest.h:62
A struct which represents a host / port pair for a socket.
Definition: OFSocket.h:189
Definition: OFHTTPRequest.h:50
A class for handling strings.
Definition: OFString.h:142
OFHTTPRequestMethod
The type of an HTTP request.
Definition: OFHTTPRequest.h:36
The HTTP version of the HTTP request.
Definition: OFHTTPRequest.h:60
OFHTTPRequestMethod OFHTTPRequestMethodParseString(OFString *string)
Returns the request method for the specified string.
Definition: OFHTTPRequest.m:62
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:82
Definition: OFHTTPRequest.h:42
A class for storing HTTP requests.
Definition: OFHTTPRequest.h:73
A class for representing IRIs, URIs, URLs and URNs, for parsing them as well as accessing parts of th...
Definition: OFIRI.h:39
Definition: OFHTTPRequest.h:52
A protocol for the creation of copies.
Definition: OFObject.h:1350
A class for storing arbitrary data in an array.
Definition: OFData.h:45
Definition: OFHTTPRequest.h:44
Definition: OFHTTPRequest.h:48
Definition: OFHTTPRequest.h:38
Definition: OFHTTPRequest.h:46
const char * OFHTTPRequestMethodName(OFHTTPRequestMethod method)
Returns a C string describing the specified request method.
Definition: OFHTTPRequest.m:86