119c15fecSAndrew Lindesay /* 254312619SAndrew 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> 1154312619SAndrew Lindesay #include <Locker.h> 1219c15fecSAndrew Lindesay #include <String.h> 130c1bbfe5SAndrew Lindesay #include <Url.h> 1419c15fecSAndrew Lindesay 1519c15fecSAndrew Lindesay 16*4080dbd6SNiels Sascha Reedijk using BPrivate::Network::BHttpHeaders; 17*4080dbd6SNiels Sascha Reedijk 1819c15fecSAndrew Lindesay class ServerSettings { 1919c15fecSAndrew Lindesay public: 200c1bbfe5SAndrew Lindesay static status_t SetBaseUrl(const BUrl& baseUrl); 2119c15fecSAndrew Lindesay static const BString GetUserAgent(); 2219c15fecSAndrew Lindesay static void AugmentHeaders(BHttpHeaders& headers); 230c1bbfe5SAndrew Lindesay static BUrl CreateFullUrl( 2419c15fecSAndrew Lindesay const BString urlPathComponents); 2519c15fecSAndrew Lindesay 263094fef3SAndrew Lindesay static bool PreferCache(); 273094fef3SAndrew Lindesay static void SetPreferCache(bool value); 283094fef3SAndrew Lindesay static bool DropCache(); 293094fef3SAndrew Lindesay static void SetDropCache(bool value); 303094fef3SAndrew Lindesay static bool ForceNoNetwork(); 313094fef3SAndrew Lindesay static void SetForceNoNetwork(bool value); 3254312619SAndrew Lindesay static bool IsClientTooOld(); 3354312619SAndrew Lindesay static void SetClientTooOld(); 343094fef3SAndrew Lindesay 3519c15fecSAndrew Lindesay private: 36d9e65badSJessica Hamilton static void _InitUserAgent(); 3719c15fecSAndrew Lindesay static const BString _GetUserAgentVersionString(); 3819c15fecSAndrew Lindesay 3954312619SAndrew Lindesay static BLocker sLock; 400c1bbfe5SAndrew Lindesay static BUrl sBaseUrl; 410c1bbfe5SAndrew Lindesay static BString sUserAgent; 420c1bbfe5SAndrew Lindesay static pthread_once_t sUserAgentInitOnce; 433094fef3SAndrew Lindesay static bool sPreferCache; 443094fef3SAndrew Lindesay static bool sDropCache; 453094fef3SAndrew Lindesay static bool sForceNoNetwork; 4654312619SAndrew Lindesay static bool sClientTooOld; 4719c15fecSAndrew Lindesay }; 4819c15fecSAndrew Lindesay 4919c15fecSAndrew Lindesay #endif // SERVER_SETTINGS_H 50