| 1 |
/* |
| 2 |
* This File is part of Davix, The IO library for HTTP based protocols |
| 3 |
* Copyright (C) CERN 2019 |
| 4 |
* Author: Georgios Bitzes <[email protected]> |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU Lesser General Public |
| 8 |
* License as published by the Free Software Foundation; either |
| 9 |
* version 2.1 of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Lesser General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public |
| 17 |
* License along with this library; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 |
* |
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef DAVIX_SESSION_FACTORY_HPP |
| 23 |
#define DAVIX_SESSION_FACTORY_HPP |
| 24 |
|
| 25 |
#include <davix_internal.hpp> |
| 26 |
|
| 27 |
#include <mutex> |
| 28 |
#include <memory> |
| 29 |
|
| 30 |
namespace Davix { |
| 31 |
|
| 32 |
class NEONSessionFactory; |
| 33 |
class CurlSessionFactory; |
| 34 |
class Uri; |
| 35 |
|
| 36 |
//------------------------------------------------------------------------------ |
| 37 |
// Store session factories of both neon and curl implementations. |
| 38 |
//------------------------------------------------------------------------------ |
| 39 |
class SessionFactory { |
| 40 |
public: |
| 41 |
//---------------------------------------------------------------------------- |
| 42 |
// Constructor |
| 43 |
//---------------------------------------------------------------------------- |
| 44 |
SessionFactory(); |
| 45 |
|
| 46 |
//---------------------------------------------------------------------------- |
| 47 |
// Destructor |
| 48 |
//---------------------------------------------------------------------------- |
| 49 |
virtual ~SessionFactory(); |
| 50 |
|
| 51 |
//---------------------------------------------------------------------------- |
| 52 |
// Get neon session factory |
| 53 |
//---------------------------------------------------------------------------- |
| 54 |
NEONSessionFactory& getNeon(); |
| 55 |
|
| 56 |
//---------------------------------------------------------------------------- |
| 57 |
// Get curl session factory |
| 58 |
//---------------------------------------------------------------------------- |
| 59 |
CurlSessionFactory& getCurl(); |
| 60 |
|
| 61 |
//---------------------------------------------------------------------------- |
| 62 |
// Set caching on or off |
| 63 |
//---------------------------------------------------------------------------- |
| 64 |
void setSessionCaching(bool caching); |
| 65 |
|
| 66 |
//---------------------------------------------------------------------------- |
| 67 |
// Get caching status |
| 68 |
//---------------------------------------------------------------------------- |
| 69 |
bool getSessionCaching() const; |
| 70 |
|
| 71 |
//---------------------------------------------------------------------------- |
| 72 |
// "httpize" protocol |
| 73 |
//---------------------------------------------------------------------------- |
| 74 |
static std::string httpizeProtocol(const std::string &protocol); |
| 75 |
|
| 76 |
//---------------------------------------------------------------------------- |
| 77 |
// Create session key based on Uri |
| 78 |
//---------------------------------------------------------------------------- |
| 79 |
static std::string makeSessionKey(const Uri &uri); |
| 80 |
|
| 81 |
protected: |
| 82 |
std::unique_ptr<NEONSessionFactory> _neon_factory; |
| 83 |
std::unique_ptr<CurlSessionFactory> _curl_factory; |
| 84 |
|
| 85 |
}; |
| 86 |
|
| 87 |
} |
| 88 |
|
| 89 |
#endif |
| 90 |
|