Debian Codegraph @

src/utils/CompatibilityHacks.hpp

raw
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_COMPATIBILITY_HACKS_HPP
23 #define DAVIX_COMPATIBILITY_HACKS_HPP
24
25 #include <utils/davix_uri.hpp>
26 #include <params/davixrequestparams.hpp>
27 #include <string>
28 #include "../backend/BackendRequest.hpp"
29
30
31 namespace Davix {
32
33 class BackendRequest;
34
35 //------------------------------------------------------------------------------
36 // A selection of compatibility hacks and procedures. Proceed with care.
37 //------------------------------------------------------------------------------
38 class CompatibilityHacks {
39 public:
40 //----------------------------------------------------------------------------
41 // Azure has a rather restrictive limit of 256 MB uploaded per each HTTP
42 // request.
43 //
44 // In case more than 256MB needs to be uploaded, we follow Azure's chunked
45 // upload mechanism and commit at the end.
46 //
47 // All is good if davix _knows_ we're writing to Azure. What happens if we're
48 // just redirected to a pre-signed Azure endpoint?
49 //
50 // We need to guess if we're talking to Azure after a redirect, and engage
51 // the chunking mechanim as before.
52 //
53 // Function returns true if Azure mechanism was engaged, false otherwise.
54 // (False means "This is not an Azure URL")
55 //----------------------------------------------------------------------------
56 static bool azureChunkedUpload(const std::string &requestType, const Uri& uri, Context &context, const RequestParams &params, ContentProvider &provider, DavixError** err);
57
58 //----------------------------------------------------------------------------
59 // Heuristic to check if URL + requestType should engage the Azure
60 // chunk-upload mechanism.
61 //----------------------------------------------------------------------------
62 static bool shouldEngageAzureChunkedUpload(const std::string &requestType, const Uri& uri);
63
64 //----------------------------------------------------------------------------
65 // Dynafed-assisted multi-chunk S3 upload.
66 // Returns if dynafed mechanism was engaged.
67 //----------------------------------------------------------------------------
68 static bool dynafedAssistedS3Upload(const BackendRequest &originatingRequest, const Uri& uri, Context &context, const RequestParams &params, ContentProvider &provider, DavixError** err);
69
70
71
72
73 };
74
75
76 }
77
78 #endif