ObjFW
OFHTTPRequest.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2021 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 "OFString.h"
18 
19 #import "socket.h"
20 
21 OF_ASSUME_NONNULL_BEGIN
22 
23 @class OFURL;
24 @class OFDictionary OF_GENERIC(KeyType, ObjectType);
25 @class OFData;
26 @class OFString;
27 
33 typedef enum {
51 
60  unsigned char major;
62  unsigned char minor;
63 };
66 
73 {
74  OFURL *_URL;
76  of_http_request_protocol_version_t _protocolVersion;
77  OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers;
78  of_socket_address_t _remoteAddress;
79  bool _hasRemoteAddress;
80  OF_RESERVE_IVARS(OFHTTPRequest, 4)
81 }
82 
86 @property (copy, nonatomic) OFURL *URL;
87 
91 @property (nonatomic) of_http_request_protocol_version_t protocolVersion;
92 
96 @property (copy, nonatomic) OFString *protocolVersionString;
97 
101 @property (nonatomic) of_http_request_method_t method;
102 
106 @property OF_NULLABLE_PROPERTY (copy, nonatomic)
107  OFDictionary OF_GENERIC(OFString *, OFString *) *headers;
108 
114 @property OF_NULLABLE_PROPERTY (nonatomic)
115  const of_socket_address_t *remoteAddress;
116 
122 + (instancetype)request;
123 
130 + (instancetype)requestWithURL: (OFURL *)URL;
131 
138 - (instancetype)initWithURL: (OFURL *)URL;
139 @end
140 
141 #ifdef __cplusplus
142 extern "C" {
143 #endif
150 extern const char *_Nullable of_http_request_method_to_string(
151  of_http_request_method_t method);
152 
160  OFString *string);
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 OF_ASSUME_NONNULL_END
of_http_request_method_t of_http_request_method_from_string(OFString *string)
Returns the request method for the specified string.
Definition: OFHTTPRequest.m:58
const char *_Nullable of_http_request_method_to_string(of_http_request_method_t method)
Returns a C string describing the specified request method.
Definition: OFHTTPRequest.m:33
of_http_request_method_t
The type of an HTTP request.
Definition: OFHTTPRequest.h:33
@ OF_HTTP_REQUEST_METHOD_CONNECT
Definition: OFHTTPRequest.h:49
@ OF_HTTP_REQUEST_METHOD_OPTIONS
Definition: OFHTTPRequest.h:35
@ OF_HTTP_REQUEST_METHOD_POST
Definition: OFHTTPRequest.h:41
@ OF_HTTP_REQUEST_METHOD_GET
Definition: OFHTTPRequest.h:37
@ OF_HTTP_REQUEST_METHOD_TRACE
Definition: OFHTTPRequest.h:47
@ OF_HTTP_REQUEST_METHOD_HEAD
Definition: OFHTTPRequest.h:39
@ OF_HTTP_REQUEST_METHOD_DELETE
Definition: OFHTTPRequest.h:45
@ OF_HTTP_REQUEST_METHOD_PUT
Definition: OFHTTPRequest.h:43
A class for storing arbitrary data in an array.
Definition: OFData.h:40
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:58
A class for storing HTTP requests.
Definition: OFHTTPRequest.h:74
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
A class for handling strings.
Definition: OFString.h:132
A class for parsing URLs and accessing parts of it.
Definition: OFURL.h:34
A protocol for the creation of copies.
Definition: OFObject.h:1187
The HTTP version of the HTTP request.
Definition: OFHTTPRequest.h:58
unsigned char minor
Definition: OFHTTPRequest.h:62
unsigned char major
Definition: OFHTTPRequest.h:60
A struct which represents a host / port pair for a socket.
Definition: socket.h:136