ObjFW
OFHTTPClient.h
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 
19 #ifndef OF_HAVE_SOCKETS
20 # error No sockets available!
21 #endif
22 
23 OF_ASSUME_NONNULL_BEGIN
24 
25 @class OFHTTPClient;
26 @class OFHTTPRequest;
27 @class OFHTTPResponse;
28 @class OFURL;
29 @class OFTCPSocket;
30 @class OFDictionary OF_GENERIC(KeyType, ObjectType);
31 
38 @optional
51 - (void)client: (OFHTTPClient *)client
52  didCreateSocket: (OF_KINDOF(OFTCPSocket *))socket
53  request: (OFHTTPRequest *)request;
54 
64 - (void)client: (OFHTTPClient *)client
65  didReceiveHeaders: (OFDictionary OF_GENERIC(OFString *, OFString *) *)headers
66  statusCode: (int)statusCode
67  request: (OFHTTPRequest *)request;
68 
93 - (bool)client: (OFHTTPClient *)client
94  shouldFollowRedirect: (OFURL *)URL
95  statusCode: (int)statusCode
96  request: (OFHTTPRequest *)request
97  response: (OFHTTPResponse *)response;
98 @end
99 
106 {
107  id <OFHTTPClientDelegate> _Nullable _delegate;
108  bool _insecureRedirectsAllowed;
109  OFTCPSocket *_Nullable _socket;
110  OFURL *_Nullable _lastURL;
111  bool _lastWasHEAD;
112  OFHTTPResponse *_Nullable _lastResponse;
113 }
114 
118 @property OF_NULLABLE_PROPERTY (nonatomic, assign)
119  id <OFHTTPClientDelegate> delegate;
120 
125 
131 + (instancetype)client;
132 
138 - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request;
139 
149 - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request
150  redirects: (size_t)redirects;
151 
155 - (void)close;
156 @end
157 
158 OF_ASSUME_NONNULL_END
nonatomic
Definition: OFHTTPClient.h:118
A delegate for OFHTTPClient.
Definition: OFHTTPClient.h:30
A class for handling strings.
Definition: OFString.h:114
bool insecureRedirectsAllowed
Definition: OFHTTPClient.h:124
A class for parsing URLs and accessing parts of it.
Definition: OFURL.h:29
A class which provides methods to create and use TCP sockets.
Definition: OFTCPSocket.h:61
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:54
The root class for all other classes inside ObjFW.
Definition: OFObject.h:379
A class for storing HTTP requests.
Definition: OFHTTPRequest.h:69
A class for representing an HTTP request reply as a stream.
Definition: OFHTTPResponse.h:30
A class for performing HTTP requests.
Definition: OFHTTPClient.h:105
void close()
Closes connections that are still open due to keep-alive.
Definition: OFHTTPClient.m:711