mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 09:18:55 +00:00
parent
8d04ee3e01
commit
6c55bcfdd8
@ -110,7 +110,6 @@ bool AdditionalHeader::Load(const char* file)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ADDHEAD> paddhead(new ADDHEAD);
|
|
||||||
if(0 == strncasecmp(key.c_str(), ADD_HEAD_REGEX, strlen(ADD_HEAD_REGEX))){
|
if(0 == strncasecmp(key.c_str(), ADD_HEAD_REGEX, strlen(ADD_HEAD_REGEX))){
|
||||||
// regex
|
// regex
|
||||||
if(key.size() <= strlen(ADD_HEAD_REGEX)){
|
if(key.size() <= strlen(ADD_HEAD_REGEX)){
|
||||||
@ -129,23 +128,12 @@ bool AdditionalHeader::Load(const char* file)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set
|
addheadlist.emplace_back(std::move(preg), key, head, value);
|
||||||
paddhead->pregex = std::move(preg);
|
|
||||||
paddhead->basestring = key;
|
|
||||||
paddhead->headkey = head;
|
|
||||||
paddhead->headvalue = value;
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
// not regex, directly comparing
|
// not regex, directly comparing
|
||||||
paddhead->pregex.reset(nullptr);
|
addheadlist.emplace_back(nullptr, key, head, value);
|
||||||
paddhead->basestring = key;
|
|
||||||
paddhead->headkey = head;
|
|
||||||
paddhead->headvalue = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add list
|
|
||||||
addheadlist.push_back(std::move(paddhead));
|
|
||||||
|
|
||||||
// set flag
|
// set flag
|
||||||
is_enable = true;
|
is_enable = true;
|
||||||
}
|
}
|
||||||
@ -177,10 +165,7 @@ bool AdditionalHeader::AddHeader(headers_t& meta, const char* path) const
|
|||||||
// Because to allow duplicate key, and then scanning the entire table.
|
// Because to allow duplicate key, and then scanning the entire table.
|
||||||
//
|
//
|
||||||
for(addheadlist_t::const_iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter){
|
for(addheadlist_t::const_iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter){
|
||||||
const ADDHEAD *paddhead = iter->get();
|
const add_header *paddhead = &*iter;
|
||||||
if(!paddhead){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(paddhead->pregex){
|
if(paddhead->pregex){
|
||||||
// regex
|
// regex
|
||||||
@ -230,11 +215,10 @@ bool AdditionalHeader::Dump() const
|
|||||||
ssdbg << "Additional Header list[" << addheadlist.size() << "] = {" << std::endl;
|
ssdbg << "Additional Header list[" << addheadlist.size() << "] = {" << std::endl;
|
||||||
|
|
||||||
for(addheadlist_t::const_iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter, ++cnt){
|
for(addheadlist_t::const_iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter, ++cnt){
|
||||||
const ADDHEAD *paddhead = iter->get();
|
const add_header *paddhead = &*iter;
|
||||||
|
|
||||||
ssdbg << " [" << cnt << "] = {" << std::endl;
|
ssdbg << " [" << cnt << "] = {" << std::endl;
|
||||||
|
|
||||||
if(paddhead){
|
|
||||||
if(paddhead->pregex){
|
if(paddhead->pregex){
|
||||||
ssdbg << " type\t\t--->\tregex" << std::endl;
|
ssdbg << " type\t\t--->\tregex" << std::endl;
|
||||||
}else{
|
}else{
|
||||||
@ -242,7 +226,6 @@ bool AdditionalHeader::Dump() const
|
|||||||
}
|
}
|
||||||
ssdbg << " base std::string\t--->\t" << paddhead->basestring << std::endl;
|
ssdbg << " base std::string\t--->\t" << paddhead->basestring << std::endl;
|
||||||
ssdbg << " add header\t--->\t" << paddhead->headkey << ": " << paddhead->headvalue << std::endl;
|
ssdbg << " add header\t--->\t" << paddhead->headkey << ": " << paddhead->headvalue << std::endl;
|
||||||
}
|
|
||||||
ssdbg << " }" << std::endl;
|
ssdbg << " }" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,20 +30,36 @@
|
|||||||
//----------------------------------------------
|
//----------------------------------------------
|
||||||
// Structure / Typedef
|
// Structure / Typedef
|
||||||
//----------------------------------------------
|
//----------------------------------------------
|
||||||
typedef struct add_header{
|
struct add_header{
|
||||||
|
add_header(std::unique_ptr<regex_t> pregex, std::string basestring, std::string headkey, std::string headvalue)
|
||||||
|
: pregex(std::move(pregex))
|
||||||
|
, basestring(std::move(basestring))
|
||||||
|
, headkey(std::move(headkey))
|
||||||
|
, headvalue(std::move(headvalue))
|
||||||
|
{}
|
||||||
~add_header() {
|
~add_header() {
|
||||||
if(pregex){
|
if(pregex){
|
||||||
regfree(pregex.get());
|
regfree(pregex.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_header(const add_header&) = delete;
|
||||||
|
add_header(add_header&& val)
|
||||||
|
: pregex(std::move(val.pregex))
|
||||||
|
, basestring(std::move(val.basestring))
|
||||||
|
, headkey(std::move(val.headkey))
|
||||||
|
, headvalue(std::move(val.headvalue))
|
||||||
|
{}
|
||||||
|
add_header& operator=(const add_header&) = delete;
|
||||||
|
add_header& operator=(add_header&&) = delete;
|
||||||
|
|
||||||
std::unique_ptr<regex_t> pregex; // not nullptr means using regex, nullptr means comparing suffix directly.
|
std::unique_ptr<regex_t> pregex; // not nullptr means using regex, nullptr means comparing suffix directly.
|
||||||
std::string basestring;
|
std::string basestring;
|
||||||
std::string headkey;
|
std::string headkey;
|
||||||
std::string headvalue;
|
std::string headvalue;
|
||||||
}ADDHEAD;
|
};
|
||||||
|
|
||||||
typedef std::vector<std::unique_ptr<ADDHEAD>> addheadlist_t;
|
typedef std::vector<add_header> addheadlist_t;
|
||||||
|
|
||||||
//----------------------------------------------
|
//----------------------------------------------
|
||||||
// Class AdditionalHeader
|
// Class AdditionalHeader
|
||||||
|
Loading…
Reference in New Issue
Block a user