xref: /haiku/src/apps/haikudepot/server/ServerSettings.h (revision 4080dbd635ecd3e71aca18a5f2d32374f4b88c91)
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 using BPrivate::Network::BHttpHeaders;
17 
18 class ServerSettings {
19 public:
20 		static status_t					SetBaseUrl(const BUrl& baseUrl);
21 		static const BString			GetUserAgent();
22 		static void						AugmentHeaders(BHttpHeaders& headers);
23 		static BUrl						CreateFullUrl(
24 											const BString urlPathComponents);
25 
26 		static bool						PreferCache();
27 		static void						SetPreferCache(bool value);
28 		static bool						DropCache();
29 		static void						SetDropCache(bool value);
30 		static bool						ForceNoNetwork();
31 		static void						SetForceNoNetwork(bool value);
32 		static bool						IsClientTooOld();
33 		static void						SetClientTooOld();
34 
35 private:
36 		static void						_InitUserAgent();
37 		static const BString			_GetUserAgentVersionString();
38 
39 		static BLocker			sLock;
40 		static BUrl						sBaseUrl;
41 		static BString					sUserAgent;
42 		static pthread_once_t			sUserAgentInitOnce;
43 		static bool						sPreferCache;
44 		static bool						sDropCache;
45 		static bool						sForceNoNetwork;
46 		static bool						sClientTooOld;
47 };
48 
49 #endif // SERVER_SETTINGS_H
50