ObjFW
OFHTTPServer.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
3  * Jonathan Schleifer <js@webkeks.org>
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 OFHTTPServer;
26 @class OFHTTPRequest;
27 @class OFHTTPResponse;
28 @class OFTCPSocket;
29 @class OFException;
30 
45 - (void)server: (OFHTTPServer*)server
46  didReceiveRequest: (OFHTTPRequest*)request
47  response: (OFHTTPResponse*)response;
48 
49 #ifdef OF_HAVE_OPTIONAL_PROTOCOLS
50 @optional
51 #endif
52 
63 - (bool)server: (OFHTTPServer*)server
64  didReceiveExceptionOnListeningSocket: (OFException*)exception;
65 @end
66 
73 {
74  OFString *_host;
75  uint16_t _port;
76  id <OFHTTPServerDelegate> _delegate;
77  OFString *_name;
78  OFTCPSocket *_listeningSocket;
79 }
80 
81 #ifdef OF_HAVE_PROPERTIES
82 @property OF_NULLABLE_PROPERTY (copy) OFString *host;
83 @property uint16_t port;
84 @property OF_NULLABLE_PROPERTY (assign) id <OFHTTPServerDelegate> delegate;
85 @property OF_NULLABLE_PROPERTY (copy) OFString *name;
86 #endif
87 
93 + (instancetype)server;
94 
100 - (void)setHost: (OFString*)host;
101 
107 - (nullable OFString*)host;
108 
114 - (void)setPort: (uint16_t)port;
115 
121 - (uint16_t)port;
122 
128 - (void)setDelegate: (nullable id <OFHTTPServerDelegate>)delegate;
129 
135 - (nullable id <OFHTTPServerDelegate>)delegate;
136 
142 - (void)setName: (nullable OFString*)name;
143 
149 - (nullable OFString*)name;
150 
154 - (void)start;
155 
161 - (void)stop;
162 @end
163 
164 @interface OFObject (OFHTTPServerDelegate) <OFHTTPServerDelegate>
165 @end
166 
167 OF_ASSUME_NONNULL_END
The root class for all other classes inside ObjFW.
Definition: OFObject.h:364
A class for representing an HTTP request reply as a stream.
Definition: OFHTTPResponse.h:29
A delegate for OFHTTPServer.
Definition: OFHTTPServer.h:36
A class for handling strings.
Definition: OFString.h:91
A class which provides functions to create and use TCP sockets.
Definition: OFTCPSocket.h:61
A class for creating a simple HTTP server inside of applications.
Definition: OFHTTPServer.h:72
A class for storing HTTP requests.
Definition: OFHTTPRequest.h:73
The base class for all exceptions in ObjFW.
Definition: OFException.h:144