ObjFW
OFHTTPRequest.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFObject.h"
17 #import "OFSocket.h"
18 #import "OFString.h"
19 
20 OF_ASSUME_NONNULL_BEGIN
21 
22 @class OFData;
23 @class OFDictionary OF_GENERIC(KeyType, ObjectType);
24 @class OFIRI;
25 @class OFString;
26 
32 typedef enum {
50 
56 typedef struct OF_BOXABLE OFHTTPRequestProtocolVersion {
58  unsigned char major;
60  unsigned char minor;
62 
68 OF_SUBCLASSING_RESTRICTED
70 {
71  OFIRI *_IRI;
72  OFHTTPRequestMethod _method;
73  OFHTTPRequestProtocolVersion _protocolVersion;
74  OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers;
75  OFSocketAddress _remoteAddress;
76  bool _hasRemoteAddress;
77 }
78 
82 @property (copy, nonatomic) OFIRI *IRI;
83 
90 @property (nonatomic) OFHTTPRequestProtocolVersion protocolVersion;
91 
100 @property (copy, nonatomic) OFString *protocolVersionString;
105 @property (nonatomic) OFHTTPRequestMethod method;
110 @property OF_NULLABLE_PROPERTY (copy, nonatomic)
111  OFDictionary OF_GENERIC(OFString *, OFString *) *headers;
118 @property OF_NULLABLE_PROPERTY (nonatomic) const OFSocketAddress *remoteAddress;
126 + (instancetype)requestWithIRI: (OFIRI *)IRI;
127 
134 - (instancetype)initWithIRI: (OFIRI *)IRI;
135 
136 - (instancetype)init OF_UNAVAILABLE;
137 @end
138 
139 #ifdef __cplusplus
140 extern "C" {
141 #endif
142 
148 extern const char *_Nullable OFHTTPRequestMethodName(
149  OFHTTPRequestMethod method);
150 
160 #ifdef __cplusplus
161 }
162 #endif
163 
164 OF_ASSUME_NONNULL_END
unsigned char minor
Definition: OFHTTPRequest.h:60
The root class for all other classes inside ObjFW.
Definition: OFObject.h:686
Definition: OFHTTPRequest.h:36
OFHTTPRequestMethod OFHTTPRequestMethodParseName(OFString *string)
Returns the request method for the specified string.
Definition: OFHTTPRequest.m:58
unsigned char major
Definition: OFHTTPRequest.h:58
A struct which represents a host / port pair for a socket.
Definition: OFSocket.h:182
Definition: OFHTTPRequest.h:46
A class for handling strings.
Definition: OFString.h:134
OFHTTPRequestMethod
The type of an HTTP request.
Definition: OFHTTPRequest.h:32
The HTTP version of the HTTP request.
Definition: OFHTTPRequest.h:56
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:78
Definition: OFHTTPRequest.h:38
A class for storing HTTP requests.
Definition: OFHTTPRequest.h:69
A class for representing IRIs, URIs, URLs and URNs, for parsing them as well as accessing parts of th...
Definition: OFIRI.h:35
Definition: OFHTTPRequest.h:48
A protocol for the creation of copies.
Definition: OFObject.h:1346
A class for storing arbitrary data in an array.
Definition: OFData.h:41
Definition: OFHTTPRequest.h:40
Definition: OFHTTPRequest.h:44
Definition: OFHTTPRequest.h:34
Definition: OFHTTPRequest.h:42
const char * OFHTTPRequestMethodName(OFHTTPRequestMethod method)
Returns a C string describing the specified request method.
Definition: OFHTTPRequest.m:33