| 1 |
/* |
| 2 |
* This File is part of Davix, The IO library for HTTP based protocols |
| 3 |
* Copyright (C) CERN 2013 |
| 4 |
* Author: Adrien Devresse <[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 |
#include "httpiochain.hpp" |
| 23 |
|
| 24 |
#include <davix_internal.hpp> |
| 25 |
|
| 26 |
namespace Davix{ |
| 27 |
|
| 28 |
HttpIOChain::HttpIOChain() : _start(this) |
| 29 |
{ |
| 30 |
} |
| 31 |
|
| 32 |
HttpIOChain::~HttpIOChain(){} |
| 33 |
|
| 34 |
|
| 35 |
HttpIOChain* HttpIOChain::add(HttpIOChain* elem){ |
| 36 |
_next.reset(elem); |
| 37 |
if(_next.get() != NULL){ |
| 38 |
_next->_start = this->_start; |
| 39 |
} |
| 40 |
return _next.get(); |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
// calculate hecksum |
| 46 |
void HttpIOChain::checksum(IOChainContext & iocontext, std::string & checksm, const std::string & chk_algo){ |
| 47 |
CHAIN_FORWARD(checksum(iocontext, checksm, chk_algo)); |
| 48 |
} |
| 49 |
|
| 50 |
// calc replica |
| 51 |
std::vector<DavFile> & HttpIOChain::getReplicas(IOChainContext & iocontext, std::vector<DavFile> & vec){ |
| 52 |
CHAIN_FORWARD(getReplicas(iocontext, vec)); |
| 53 |
} |
| 54 |
|
| 55 |
// delete resource |
| 56 |
void HttpIOChain::deleteResource(IOChainContext & iocontext){ |
| 57 |
CHAIN_FORWARD(deleteResource(iocontext)); |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
// make collection |
| 62 |
void HttpIOChain::makeCollection(IOChainContext & iocontext){ |
| 63 |
CHAIN_FORWARD(makeCollection(iocontext)); |
| 64 |
} |
| 65 |
|
| 66 |
// move/rename resource |
| 67 |
void HttpIOChain::move(IOChainContext & iocontext, const std::string & target_url){ |
| 68 |
CHAIN_FORWARD(move(iocontext, target_url)); |
| 69 |
} |
| 70 |
|
| 71 |
StatInfo & HttpIOChain::statInfo(IOChainContext & iocontext, StatInfo &st_info){ |
| 72 |
CHAIN_FORWARD(statInfo(iocontext, st_info)); |
| 73 |
} |
| 74 |
|
| 75 |
QuotaInfo & HttpIOChain::quotaInfo(IOChainContext & iocontext, QuotaInfo &info) { |
| 76 |
CHAIN_FORWARD(quotaInfo(iocontext, info)); |
| 77 |
} |
| 78 |
|
| 79 |
bool HttpIOChain::nextSubItem(IOChainContext &iocontext, std::string &entry_name, StatInfo &info){ |
| 80 |
CHAIN_FORWARD(nextSubItem(iocontext, entry_name, info)); |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
bool HttpIOChain::open(IOChainContext & iocontext, int flags){ |
| 85 |
CHAIN_FORWARD(open(iocontext, flags)); |
| 86 |
} |
| 87 |
|
| 88 |
void HttpIOChain::prefetchInfo(IOChainContext & iocontext, off_t offset, dav_size_t size_read, advise_t adv){ |
| 89 |
CHAIN_FORWARD(prefetchInfo(iocontext, offset, size_read, adv)); |
| 90 |
} |
| 91 |
|
| 92 |
dav_ssize_t HttpIOChain::readFull(IOChainContext & iocontext, std::vector<char> &buffer){ |
| 93 |
CHAIN_FORWARD(readFull(iocontext, buffer)); |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
dav_ssize_t HttpIOChain::readFull(IOChainContext & iocontext, std::string & str_buffer){ |
| 98 |
std::vector<char> buffer; |
| 99 |
dav_ssize_t s = readFull(iocontext, buffer); |
| 100 |
str_buffer.assign(buffer.begin(), buffer.end()); |
| 101 |
return s; |
| 102 |
} |
| 103 |
|
| 104 |
// read to fd |
| 105 |
dav_ssize_t HttpIOChain::readToFd(IOChainContext & iocontext, int fd, dav_size_t size){ |
| 106 |
CHAIN_FORWARD(readToFd(iocontext, fd, size)); |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
dav_ssize_t HttpIOChain::preadVec(IOChainContext & iocontext, const DavIOVecInput *input_vec, DavIOVecOuput *output_vec, const dav_size_t count_vec){ |
| 111 |
CHAIN_FORWARD(preadVec(iocontext, input_vec, output_vec, count_vec)); |
| 112 |
} |
| 113 |
|
| 114 |
void HttpIOChain::resetIO(IOChainContext & iocontext){ |
| 115 |
CHAIN_FORWARD(resetIO(iocontext)); |
| 116 |
} |
| 117 |
|
| 118 |
dav_ssize_t HttpIOChain::pread(IOChainContext & iocontext, void *buf, dav_size_t count, dav_off_t offset){ |
| 119 |
CHAIN_FORWARD(pread(iocontext, buf,count, offset)); |
| 120 |
} |
| 121 |
|
| 122 |
dav_ssize_t HttpIOChain::read(IOChainContext & iocontext, void *buf, dav_size_t count){ |
| 123 |
CHAIN_FORWARD(read(iocontext, buf, count)); |
| 124 |
} |
| 125 |
|
| 126 |
dav_off_t HttpIOChain::lseek(IOChainContext & iocontext, dav_off_t offset, int flags){ |
| 127 |
CHAIN_FORWARD(lseek(iocontext, offset, flags)); |
| 128 |
} |
| 129 |
|
| 130 |
dav_ssize_t HttpIOChain::write(IOChainContext & iocontext, const void *buf, dav_size_t count){ |
| 131 |
CHAIN_FORWARD(write(iocontext, buf, count)); |
| 132 |
} |
| 133 |
|
| 134 |
bool HttpIOChain::writeFromBuffer(IOChainContext& iocontext, const char* buff, |
| 135 |
dav_size_t size, const std::string& uploadId, |
| 136 |
std::vector<std::string>& etags, |
| 137 |
int partNumber) { |
| 138 |
CHAIN_FORWARD(writeFromBuffer(iocontext,buff,size,uploadId,etags,partNumber)); |
| 139 |
} |
| 140 |
|
| 141 |
dav_ssize_t HttpIOChain::writeFromProvider(IOChainContext & iocontext, ContentProvider &provider) { |
| 142 |
CHAIN_FORWARD(writeFromProvider(iocontext, provider)); |
| 143 |
} |
| 144 |
|
| 145 |
std::string HttpIOChain::initiateMultipart(IOChainContext& iocontext) { |
| 146 |
CHAIN_FORWARD(initiateMultipart(iocontext)); |
| 147 |
} |
| 148 |
|
| 149 |
bool HttpIOChain::commitChunks(IOChainContext& iocontext, |
| 150 |
const std::string &uploadId, |
| 151 |
const std::vector<std::string> &etags) { |
| 152 |
CHAIN_FORWARD(commitChunks(iocontext, uploadId, etags)); |
| 153 |
} |
| 154 |
|
| 155 |
} // Davix |