ObjFW
Loading...
Searching...
No Matches
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
24OF_ASSUME_NONNULL_BEGIN
25
26@class OFData;
27@class OFDictionary OF_GENERIC(KeyType, ObjectType);
28@class OFIRI;
29@class OFString;
30
54
60typedef struct OF_BOXABLE OFHTTPRequestProtocolVersion {
62 unsigned char major;
64 unsigned char minor;
66
72OF_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;
94@property (nonatomic) OFHTTPRequestProtocolVersion protocolVersion;
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
144extern "C" {
145#endif
152extern OFString *_Nullable OFHTTPRequestMethodString(
153 OFHTTPRequestMethod method);
154
164
173extern 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
192OF_ASSUME_NONNULL_END
OFHTTPRequestMethod
The type of an HTTP request.
Definition OFHTTPRequest.h:36
@ OFHTTPRequestMethodHead
Definition OFHTTPRequest.h:42
@ OFHTTPRequestMethodTrace
Definition OFHTTPRequest.h:50
@ OFHTTPRequestMethodDelete
Definition OFHTTPRequest.h:48
@ OFHTTPRequestMethodPut
Definition OFHTTPRequest.h:46
@ OFHTTPRequestMethodOptions
Definition OFHTTPRequest.h:38
@ OFHTTPRequestMethodGet
Definition OFHTTPRequest.h:40
@ OFHTTPRequestMethodPost
Definition OFHTTPRequest.h:44
@ OFHTTPRequestMethodConnect
Definition OFHTTPRequest.h:52
OFHTTPRequestMethod OFHTTPRequestMethodParseName(OFString *string)
Returns the request method for the specified string.
Definition OFHTTPRequest.m:93
OFHTTPRequestMethod OFHTTPRequestMethodParseString(OFString *string)
Returns the request method for the specified string.
Definition OFHTTPRequest.m:62
OFString * OFHTTPRequestMethodString(OFHTTPRequestMethod method)
Returns a string describing the specified request method.
Definition OFHTTPRequest.m:37
const char * OFHTTPRequestMethodName(OFHTTPRequestMethod method)
Returns a C string describing the specified request method.
Definition OFHTTPRequest.m:86
A class for storing arbitrary data in an array.
Definition OFData.h:46
An abstract class for storing objects in a dictionary.
Definition OFDictionary.h:84
A class for storing HTTP requests.
Definition OFHTTPRequest.h:75
A class for representing IRIs, URIs, URLs and URNs, for parsing them as well as accessing parts of th...
Definition OFIRI.h:41
The root class for all other classes inside ObjFW.
Definition OFObject.h:692
A class for handling strings.
Definition OFString.h:139
A protocol for the creation of copies.
Definition OFObject.h:1350
The HTTP version of the HTTP request.
Definition OFHTTPRequest.h:60
unsigned char minor
Definition OFHTTPRequest.h:64
unsigned char major
Definition OFHTTPRequest.h:62
A struct which represents a host / port pair for a socket.
Definition OFSocket.h:186