119c15fecSAndrew Lindesay /* 2*54312619SAndrew Lindesay * Copyright 2017-2018, Andrew Lindesay <apl@lindesay.co.nz>. 319c15fecSAndrew Lindesay * All rights reserved. Distributed under the terms of the MIT License. 419c15fecSAndrew Lindesay */ 519c15fecSAndrew Lindesay 619c15fecSAndrew Lindesay #ifndef SERVER_SETTINGS_H 719c15fecSAndrew Lindesay #define SERVER_SETTINGS_H 819c15fecSAndrew Lindesay 919c15fecSAndrew Lindesay #include <File.h> 1019c15fecSAndrew Lindesay #include <HttpHeaders.h> 11*54312619SAndrew Lindesay #include <Locker.h> 1219c15fecSAndrew Lindesay #include <String.h> 130c1bbfe5SAndrew Lindesay #include <Url.h> 1419c15fecSAndrew Lindesay 1519c15fecSAndrew Lindesay 1619c15fecSAndrew Lindesay class ServerSettings { 1719c15fecSAndrew Lindesay public: 180c1bbfe5SAndrew Lindesay static status_t SetBaseUrl(const BUrl& baseUrl); 1919c15fecSAndrew Lindesay static const BString GetUserAgent(); 2019c15fecSAndrew Lindesay static void AugmentHeaders(BHttpHeaders& headers); 210c1bbfe5SAndrew Lindesay static BUrl CreateFullUrl( 2219c15fecSAndrew Lindesay const BString urlPathComponents); 2319c15fecSAndrew Lindesay 243094fef3SAndrew Lindesay static bool PreferCache(); 253094fef3SAndrew Lindesay static void SetPreferCache(bool value); 263094fef3SAndrew Lindesay static bool DropCache(); 273094fef3SAndrew Lindesay static void SetDropCache(bool value); 283094fef3SAndrew Lindesay static bool ForceNoNetwork(); 293094fef3SAndrew Lindesay static void SetForceNoNetwork(bool value); 30*54312619SAndrew Lindesay static bool IsClientTooOld(); 31*54312619SAndrew Lindesay static void SetClientTooOld(); 323094fef3SAndrew Lindesay 3319c15fecSAndrew Lindesay private: 34d9e65badSJessica Hamilton static void _InitUserAgent(); 3519c15fecSAndrew Lindesay static const BString _GetUserAgentVersionString(); 3619c15fecSAndrew Lindesay 37*54312619SAndrew Lindesay static BLocker sLock; 380c1bbfe5SAndrew Lindesay static BUrl sBaseUrl; 390c1bbfe5SAndrew Lindesay static BString sUserAgent; 400c1bbfe5SAndrew Lindesay static pthread_once_t sUserAgentInitOnce; 413094fef3SAndrew Lindesay static bool sPreferCache; 423094fef3SAndrew Lindesay static bool sDropCache; 433094fef3SAndrew Lindesay static bool sForceNoNetwork; 44*54312619SAndrew Lindesay static bool sClientTooOld; 4519c15fecSAndrew Lindesay }; 4619c15fecSAndrew Lindesay 4719c15fecSAndrew Lindesay #endif // SERVER_SETTINGS_H 48