mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 01:08:54 +00:00
Merge pull request #397 from ggtakec/master
Supported User-Agent header - #383
This commit is contained in:
commit
b979d40778
@ -216,6 +216,10 @@ If this option is specified with nocopapi, the s3fs ignores it.
|
|||||||
\fB\-o\fR use_path_request_style (use legacy API calling style)
|
\fB\-o\fR use_path_request_style (use legacy API calling style)
|
||||||
Enble compatibility with S3-like APIs which do not support the virtual-host request style, by using the older path request style.
|
Enble compatibility with S3-like APIs which do not support the virtual-host request style, by using the older path request style.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-o\fR noua (suppress User-Agent header)
|
||||||
|
Usually s3fs outputs of the User-Agent in "s3fs/<version> (commit hash <hash>; <using ssl library name>)" format.
|
||||||
|
If this option is specified, s3fs suppresses the output of the User-Agent.
|
||||||
|
.TP
|
||||||
\fB\-o\fR dbglevel (default="crit")
|
\fB\-o\fR dbglevel (default="crit")
|
||||||
Set the debug message level. set value as crit(critical), err(error), warn(warning), info(information) to debug level. default debug level is critical.
|
Set the debug message level. set value as crit(critical), err(error), warn(warning), info(information) to debug level. default debug level is critical.
|
||||||
If s3fs run with "-d" option, the debug level is set information.
|
If s3fs run with "-d" option, the debug level is set information.
|
||||||
|
41
src/curl.cpp
41
src/curl.cpp
@ -271,6 +271,7 @@ mimes_t S3fsCurl::mimeTypes;
|
|||||||
int S3fsCurl::max_parallel_cnt = 5; // default
|
int S3fsCurl::max_parallel_cnt = 5; // default
|
||||||
off_t S3fsCurl::multipart_size = MULTIPART_SIZE; // default
|
off_t S3fsCurl::multipart_size = MULTIPART_SIZE; // default
|
||||||
bool S3fsCurl::is_sigv4 = true; // default
|
bool S3fsCurl::is_sigv4 = true; // default
|
||||||
|
bool S3fsCurl::is_ua = true; // default
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Class methods for S3fsCurl
|
// Class methods for S3fsCurl
|
||||||
@ -1344,6 +1345,30 @@ bool S3fsCurl::CheckIAMCredentialUpdate(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool S3fsCurl::AddUserAgent(CURL* hCurl)
|
||||||
|
{
|
||||||
|
if(!hCurl){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(S3fsCurl::IsUserAgentFlag()){
|
||||||
|
static string strua;
|
||||||
|
static bool init = false;
|
||||||
|
|
||||||
|
if(!init){
|
||||||
|
strua = "s3fs/";
|
||||||
|
strua += VERSION;
|
||||||
|
strua += " (commit hash ";
|
||||||
|
strua += COMMIT_HASH_VAL;
|
||||||
|
strua += "; ";
|
||||||
|
strua += s3fs_crypt_lib_name();
|
||||||
|
strua += ")";
|
||||||
|
init = true;
|
||||||
|
}
|
||||||
|
curl_easy_setopt(hCurl, CURLOPT_USERAGENT, strua.c_str());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int S3fsCurl::CurlDebugFunc(CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr)
|
int S3fsCurl::CurlDebugFunc(CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr)
|
||||||
{
|
{
|
||||||
if(!hcurl){
|
if(!hcurl){
|
||||||
@ -1722,6 +1747,8 @@ bool S3fsCurl::RemakeHandle(void)
|
|||||||
S3FS_PRN_ERR("request type is unknown(%d)", type);
|
S3FS_PRN_ERR("request type is unknown(%d)", type);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2133,6 +2160,7 @@ int S3fsCurl::DeleteRequest(const char* tpath)
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str());
|
||||||
curl_easy_setopt(hCurl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
curl_easy_setopt(hCurl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||||
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_DELETE;
|
type = REQTYPE_DELETE;
|
||||||
|
|
||||||
@ -2167,6 +2195,7 @@ int S3fsCurl::GetIAMCredentials(void)
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str());
|
||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void*)bodydata);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void*)bodydata);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
int result = RequestPerform();
|
int result = RequestPerform();
|
||||||
|
|
||||||
@ -2275,6 +2304,7 @@ bool S3fsCurl::PreHeadRequest(const char* tpath, const char* bpath, const char*
|
|||||||
// responseHeaders
|
// responseHeaders
|
||||||
curl_easy_setopt(hCurl, CURLOPT_HEADERDATA, (void*)&responseHeaders);
|
curl_easy_setopt(hCurl, CURLOPT_HEADERDATA, (void*)&responseHeaders);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_HEADERFUNCTION, HeaderCallback);
|
curl_easy_setopt(hCurl, CURLOPT_HEADERFUNCTION, HeaderCallback);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_HEAD;
|
type = REQTYPE_HEAD;
|
||||||
|
|
||||||
@ -2421,6 +2451,7 @@ int S3fsCurl::PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy)
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_INFILESIZE, 0); // Content-Length
|
curl_easy_setopt(hCurl, CURLOPT_INFILESIZE, 0); // Content-Length
|
||||||
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_PUTHEAD;
|
type = REQTYPE_PUTHEAD;
|
||||||
|
|
||||||
@ -2544,6 +2575,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd)
|
|||||||
}else{
|
}else{
|
||||||
curl_easy_setopt(hCurl, CURLOPT_INFILESIZE, 0); // Content-Length: 0
|
curl_easy_setopt(hCurl, CURLOPT_INFILESIZE, 0); // Content-Length: 0
|
||||||
}
|
}
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_PUT;
|
type = REQTYPE_PUT;
|
||||||
|
|
||||||
@ -2609,6 +2641,7 @@ int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, ssize_
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, S3fsCurl::DownloadWriteCallback);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, S3fsCurl::DownloadWriteCallback);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void*)this);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void*)this);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
// set info for callback func.
|
// set info for callback func.
|
||||||
// (use only fd, startpos and size, other member is not used.)
|
// (use only fd, startpos and size, other member is not used.)
|
||||||
@ -2689,6 +2722,7 @@ int S3fsCurl::CheckBucket(void)
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void*)bodydata);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void*)bodydata);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_CHKBUCKET;
|
type = REQTYPE_CHKBUCKET;
|
||||||
|
|
||||||
@ -2742,6 +2776,7 @@ int S3fsCurl::ListBucketRequest(const char* tpath, const char* query)
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void*)bodydata);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void*)bodydata);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_LISTBUCKET;
|
type = REQTYPE_LISTBUCKET;
|
||||||
|
|
||||||
@ -2856,6 +2891,7 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, string
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_POSTFIELDSIZE, 0);
|
curl_easy_setopt(hCurl, CURLOPT_POSTFIELDSIZE, 0);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_PREMULTIPOST;
|
type = REQTYPE_PREMULTIPOST;
|
||||||
|
|
||||||
@ -2968,6 +3004,7 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, string& upload_id,
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_POSTFIELDSIZE, static_cast<curl_off_t>(postdata_remaining));
|
curl_easy_setopt(hCurl, CURLOPT_POSTFIELDSIZE, static_cast<curl_off_t>(postdata_remaining));
|
||||||
curl_easy_setopt(hCurl, CURLOPT_READDATA, (void*)this);
|
curl_easy_setopt(hCurl, CURLOPT_READDATA, (void*)this);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_READFUNCTION, S3fsCurl::ReadCallback);
|
curl_easy_setopt(hCurl, CURLOPT_READFUNCTION, S3fsCurl::ReadCallback);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_COMPLETEMULTIPOST;
|
type = REQTYPE_COMPLETEMULTIPOST;
|
||||||
|
|
||||||
@ -3018,6 +3055,7 @@ int S3fsCurl::MultipartListRequest(string& body)
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void*)bodydata);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void*)bodydata);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_MULTILIST;
|
type = REQTYPE_MULTILIST;
|
||||||
|
|
||||||
@ -3070,6 +3108,7 @@ int S3fsCurl::AbortMultipartUpload(const char* tpath, string& upload_id)
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(hCurl, CURLOPT_URL, url.c_str());
|
||||||
curl_easy_setopt(hCurl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
curl_easy_setopt(hCurl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||||
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_ABORTMULTIUPLOAD;
|
type = REQTYPE_ABORTMULTIUPLOAD;
|
||||||
|
|
||||||
@ -3164,6 +3203,7 @@ int S3fsCurl::UploadMultipartPostSetup(const char* tpath, int part_num, const st
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_READFUNCTION, S3fsCurl::UploadReadCallback);
|
curl_easy_setopt(hCurl, CURLOPT_READFUNCTION, S3fsCurl::UploadReadCallback);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_READDATA, (void*)this);
|
curl_easy_setopt(hCurl, CURLOPT_READDATA, (void*)this);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_UPLOADMULTIPOST;
|
type = REQTYPE_UPLOADMULTIPOST;
|
||||||
|
|
||||||
@ -3262,6 +3302,7 @@ int S3fsCurl::CopyMultipartPostRequest(const char* from, const char* to, int par
|
|||||||
curl_easy_setopt(hCurl, CURLOPT_HEADERFUNCTION, WriteMemoryCallback);
|
curl_easy_setopt(hCurl, CURLOPT_HEADERFUNCTION, WriteMemoryCallback);
|
||||||
curl_easy_setopt(hCurl, CURLOPT_INFILESIZE, 0); // Content-Length
|
curl_easy_setopt(hCurl, CURLOPT_INFILESIZE, 0); // Content-Length
|
||||||
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, requestHeaders);
|
||||||
|
S3fsCurl::AddUserAgent(hCurl); // put User-Agent
|
||||||
|
|
||||||
type = REQTYPE_COPYMULTIPOST;
|
type = REQTYPE_COPYMULTIPOST;
|
||||||
|
|
||||||
|
@ -205,6 +205,7 @@ class S3fsCurl
|
|||||||
static int max_parallel_cnt;
|
static int max_parallel_cnt;
|
||||||
static off_t multipart_size;
|
static off_t multipart_size;
|
||||||
static bool is_sigv4;
|
static bool is_sigv4;
|
||||||
|
static bool is_ua; // User-Agent
|
||||||
|
|
||||||
// variables
|
// variables
|
||||||
CURL* hCurl;
|
CURL* hCurl;
|
||||||
@ -266,6 +267,7 @@ class S3fsCurl
|
|||||||
static bool LoadEnvSseCKeys(void);
|
static bool LoadEnvSseCKeys(void);
|
||||||
static bool LoadEnvSseKmsid(void);
|
static bool LoadEnvSseKmsid(void);
|
||||||
static bool PushbackSseKeys(std::string& onekey);
|
static bool PushbackSseKeys(std::string& onekey);
|
||||||
|
static bool AddUserAgent(CURL* hCurl);
|
||||||
|
|
||||||
static int CurlDebugFunc(CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr);
|
static int CurlDebugFunc(CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr);
|
||||||
|
|
||||||
@ -336,6 +338,8 @@ class S3fsCurl
|
|||||||
static off_t GetMultipartSize(void) { return S3fsCurl::multipart_size; }
|
static off_t GetMultipartSize(void) { return S3fsCurl::multipart_size; }
|
||||||
static bool SetSignatureV4(bool isset) { bool bresult = S3fsCurl::is_sigv4; S3fsCurl::is_sigv4 = isset; return bresult; }
|
static bool SetSignatureV4(bool isset) { bool bresult = S3fsCurl::is_sigv4; S3fsCurl::is_sigv4 = isset; return bresult; }
|
||||||
static bool IsSignatureV4(void) { return S3fsCurl::is_sigv4; }
|
static bool IsSignatureV4(void) { return S3fsCurl::is_sigv4; }
|
||||||
|
static bool SetUserAgentFlag(bool isset) { bool bresult = S3fsCurl::is_ua; S3fsCurl::is_ua = isset; return bresult; }
|
||||||
|
static bool IsUserAgentFlag(void) { return S3fsCurl::is_ua; }
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
bool CreateCurlHandle(bool force = false);
|
bool CreateCurlHandle(bool force = false);
|
||||||
|
@ -4599,6 +4599,10 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
|||||||
pathrequeststyle = true;
|
pathrequeststyle = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if(0 == STR2NCMP(arg, "noua")){
|
||||||
|
S3fsCurl::SetUserAgentFlag(false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// debug option for s3fs
|
// debug option for s3fs
|
||||||
//
|
//
|
||||||
|
@ -1109,6 +1109,12 @@ void show_help (void)
|
|||||||
" the virtual-host request style, by using the older path request\n"
|
" the virtual-host request style, by using the older path request\n"
|
||||||
" style.\n"
|
" style.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" noua (suppress User-Agent header)\n"
|
||||||
|
" Usually s3fs outputs of the User-Agent in \"s3fs/<version> (commit\n"
|
||||||
|
" hash <hash>; <using ssl library name>)\" format.\n"
|
||||||
|
" If this option is specified, s3fs suppresses the output of the\n"
|
||||||
|
" User-Agent.\n"
|
||||||
|
"\n"
|
||||||
" dbglevel (default=\"crit\")\n"
|
" dbglevel (default=\"crit\")\n"
|
||||||
" Set the debug message level. set value as crit(critical), err\n"
|
" Set the debug message level. set value as crit(critical), err\n"
|
||||||
" (error), warn(warning), info(information) to debug level.\n"
|
" (error), warn(warning), info(information) to debug level.\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user