ObjFW
OFHTTPRequest.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
3  * Jonathan Schleifer <js@heap.zone>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFObject.h"
18 #import "OFString.h"
19 
20 OF_ASSUME_NONNULL_BEGIN
21 
22 @class OFURL;
23 @class OFDictionary OF_GENERIC(KeyType, ObjectType);
24 @class OFData;
25 @class OFString;
26 
32 typedef enum {
50 
57 typedef struct {
59  uint8_t major;
61  uint8_t minor;
63 
70 {
71  OFURL *_URL;
73  of_http_request_protocol_version_t _protocolVersion;
74  OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers;
75  OFData *_Nullable _body;
76  OFString *_Nullable _remoteAddress;
77 }
78 
82 @property (nonatomic, copy) OFURL *URL;
83 
88 
92 @property OF_NULLABLE_PROPERTY (nonatomic, copy)
93  OFDictionary OF_GENERIC(OFString *, OFString *) *headers;
94 
98 @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFData *body;
99 
103 @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *remoteAddress;
104 
110 + (instancetype)request;
111 
118 + (instancetype)requestWithURL: (OFURL *)URL;
119 
126 - initWithURL: (OFURL *)URL;
127 
133 - (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion;
134 
140 - (of_http_request_protocol_version_t)protocolVersion;
141 
148 - (void)setProtocolVersionFromString: (OFString *)string;
149 
155 - (OFString *)protocolVersionString;
156 
163 - (void)setBodyFromString: (OFString *)string;
164 
172 - (void)setBodyFromString: (OFString *)string
173  encoding: (of_string_encoding_t)encoding;
174 @end
175 
176 #ifdef __cplusplus
177 extern "C" {
178 #endif
179 
185 extern const char *_Nullable of_http_request_method_to_string(
187 
195  const char *string);
196 #ifdef __cplusplus
197 }
198 #endif
199 
200 OF_ASSUME_NONNULL_END
Definition: OFHTTPRequest.h:40
Definition: OFHTTPRequest.h:46
id copy()
Returns the class.
Definition: OFObject.m:1133
A class for handling strings.
Definition: OFString.h:114
Definition: OFHTTPRequest.h:48
OFURL * URL
Definition: OFHTTPRequest.h:83
OFString * protocolVersionString()
Returns the protocol version of the HTTP request as a string.
Definition: OFHTTPRequest.m:228
A class for parsing URLs and accessing parts of it.
Definition: OFURL.h:29
of_http_request_method_t method
Definition: OFHTTPRequest.h:88
Definition: OFHTTPRequest.h:44
uint8_t major
Definition: OFHTTPRequest.h:59
nonatomic
Definition: OFHTTPRequest.h:93
The HTTP version of the HTTP request.
Definition: OFHTTPRequest.h:57
A protocol for the creation of copies.
Definition: OFObject.h:914
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:54
instancetype request()
Creates a new OFHTTPRequest.
Definition: OFHTTPRequest.m:84
The root class for all other classes inside ObjFW.
Definition: OFObject.h:379
Definition: OFHTTPRequest.h:36
A class for storing HTTP requests.
Definition: OFHTTPRequest.h:69
Definition: OFHTTPRequest.h:42
Definition: OFHTTPRequest.h:38
of_string_encoding_t
The encoding of a string.
Definition: OFString.h:53
A class for storing arbitrary data in an array.
Definition: OFData.h:34
of_http_request_method_t of_http_request_method_from_string(const char *string)
Returns the request method for the specified string.
Definition: OFHTTPRequest.m:58
Definition: OFHTTPRequest.h:34
of_http_request_method_t
The type of an HTTP request.
Definition: OFHTTPRequest.h:32
of_http_request_protocol_version_t protocolVersion()
Returns the protocol version of the HTTP request.
Definition: OFHTTPRequest.m:199
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
uint8_t minor
Definition: OFHTTPRequest.h:61