xref: /haiku/src/apps/haikudepot/server/ServerSettings.h (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 /*
2  * Copyright 2017-2018, Andrew Lindesay <apl@lindesay.co.nz>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 
6 #ifndef SERVER_SETTINGS_H
7 #define SERVER_SETTINGS_H
8 
9 #include <File.h>
10 #include <HttpHeaders.h>
11 #include <Locker.h>
12 #include <String.h>
13 #include <Url.h>
14 
15 
16 class ServerSettings {
17 public:
18 		static status_t					SetBaseUrl(const BUrl& baseUrl);
19 		static const BString			GetUserAgent();
20 		static void						AugmentHeaders(BHttpHeaders& headers);
21 		static BUrl						CreateFullUrl(
22 											const BString urlPathComponents);
23 
24 		static bool						PreferCache();
25 		static void						SetPreferCache(bool value);
26 		static bool						DropCache();
27 		static void						SetDropCache(bool value);
28 		static bool						ForceNoNetwork();
29 		static void						SetForceNoNetwork(bool value);
30 		static bool						IsClientTooOld();
31 		static void						SetClientTooOld();
32 
33 private:
34 		static void						_InitUserAgent();
35 		static const BString			_GetUserAgentVersionString();
36 
37 		static BLocker			sLock;
38 		static BUrl						sBaseUrl;
39 		static BString					sUserAgent;
40 		static pthread_once_t			sUserAgentInitOnce;
41 		static bool						sPreferCache;
42 		static bool						sDropCache;
43 		static bool						sForceNoNetwork;
44 		static bool						sClientTooOld;
45 };
46 
47 #endif // SERVER_SETTINGS_H
48