diff options
Diffstat (limited to 'linden/indra/llmessage/llhttpassetstorage.cpp')
-rw-r--r-- | linden/indra/llmessage/llhttpassetstorage.cpp | 64 |
1 files changed, 29 insertions, 35 deletions
diff --git a/linden/indra/llmessage/llhttpassetstorage.cpp b/linden/indra/llmessage/llhttpassetstorage.cpp index 49896c6..fdd521f 100644 --- a/linden/indra/llmessage/llhttpassetstorage.cpp +++ b/linden/indra/llmessage/llhttpassetstorage.cpp | |||
@@ -81,8 +81,8 @@ class LLHTTPAssetRequest : public LLAssetRequest | |||
81 | { | 81 | { |
82 | public: | 82 | public: |
83 | LLHTTPAssetRequest(LLHTTPAssetStorage *asp, const LLUUID &uuid, | 83 | LLHTTPAssetRequest(LLHTTPAssetStorage *asp, const LLUUID &uuid, |
84 | LLAssetType::EType type, LLAssetStorage::ERequestType rt, | 84 | LLAssetType::EType type, LLAssetStorage::ERequestType rt, |
85 | const char *url, CURLM *curl_multi); | 85 | const std::string& url, CURLM *curl_multi); |
86 | virtual ~LLHTTPAssetRequest(); | 86 | virtual ~LLHTTPAssetRequest(); |
87 | 87 | ||
88 | void setupCurlHandle(); | 88 | void setupCurlHandle(); |
@@ -103,7 +103,7 @@ public: | |||
103 | 103 | ||
104 | CURL *mCurlHandle; | 104 | CURL *mCurlHandle; |
105 | CURLM *mCurlMultiHandle; | 105 | CURLM *mCurlMultiHandle; |
106 | char *mURLBuffer; | 106 | std::string mURLBuffer; |
107 | struct curl_slist *mHTTPHeaders; | 107 | struct curl_slist *mHTTPHeaders; |
108 | LLVFile *mVFile; | 108 | LLVFile *mVFile; |
109 | LLUUID mTmpUUID; | 109 | LLUUID mTmpUUID; |
@@ -122,7 +122,7 @@ LLHTTPAssetRequest::LLHTTPAssetRequest(LLHTTPAssetStorage *asp, | |||
122 | const LLUUID &uuid, | 122 | const LLUUID &uuid, |
123 | LLAssetType::EType type, | 123 | LLAssetType::EType type, |
124 | LLAssetStorage::ERequestType rt, | 124 | LLAssetStorage::ERequestType rt, |
125 | const char *url, | 125 | const std::string& url, |
126 | CURLM *curl_multi) | 126 | CURLM *curl_multi) |
127 | : LLAssetRequest(uuid, type), | 127 | : LLAssetRequest(uuid, type), |
128 | mZInitialized(false) | 128 | mZInitialized(false) |
@@ -137,11 +137,7 @@ LLHTTPAssetRequest::LLHTTPAssetRequest(LLHTTPAssetStorage *asp, | |||
137 | mZInputBuffer = NULL; | 137 | mZInputBuffer = NULL; |
138 | mZInputExhausted = false; | 138 | mZInputExhausted = false; |
139 | 139 | ||
140 | mURLBuffer = new char[strlen(url) + 1]; /*Flawfinder: ignore*/ | 140 | mURLBuffer = url; |
141 | if (mURLBuffer) | ||
142 | { | ||
143 | strcpy(mURLBuffer, url); /*Flawfinder: ignore*/ | ||
144 | } | ||
145 | } | 141 | } |
146 | 142 | ||
147 | LLHTTPAssetRequest::~LLHTTPAssetRequest() | 143 | LLHTTPAssetRequest::~LLHTTPAssetRequest() |
@@ -156,7 +152,6 @@ LLHTTPAssetRequest::~LLHTTPAssetRequest() | |||
156 | { | 152 | { |
157 | curl_slist_free_all(mHTTPHeaders); | 153 | curl_slist_free_all(mHTTPHeaders); |
158 | } | 154 | } |
159 | delete[] mURLBuffer; | ||
160 | delete mVFile; | 155 | delete mVFile; |
161 | finishCompressedUpload(); | 156 | finishCompressedUpload(); |
162 | } | 157 | } |
@@ -242,7 +237,7 @@ void LLHTTPAssetRequest::setupCurlHandle() | |||
242 | mCurlHandle = curl_easy_init(); | 237 | mCurlHandle = curl_easy_init(); |
243 | curl_easy_setopt(mCurlHandle, CURLOPT_NOSIGNAL, 1); | 238 | curl_easy_setopt(mCurlHandle, CURLOPT_NOSIGNAL, 1); |
244 | curl_easy_setopt(mCurlHandle, CURLOPT_NOPROGRESS, 1); | 239 | curl_easy_setopt(mCurlHandle, CURLOPT_NOPROGRESS, 1); |
245 | curl_easy_setopt(mCurlHandle, CURLOPT_URL, mURLBuffer); | 240 | curl_easy_setopt(mCurlHandle, CURLOPT_URL, mURLBuffer.c_str()); |
246 | curl_easy_setopt(mCurlHandle, CURLOPT_PRIVATE, this); | 241 | curl_easy_setopt(mCurlHandle, CURLOPT_PRIVATE, this); |
247 | if (LLAssetStorage::RT_DOWNLOAD == mRequestType) | 242 | if (LLAssetStorage::RT_DOWNLOAD == mRequestType) |
248 | { | 243 | { |
@@ -400,9 +395,9 @@ size_t LLHTTPAssetRequest::curlCompressedUploadCallback( | |||
400 | 395 | ||
401 | LLHTTPAssetStorage::LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, | 396 | LLHTTPAssetStorage::LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, |
402 | LLVFS *vfs, const LLHost &upstream_host, | 397 | LLVFS *vfs, const LLHost &upstream_host, |
403 | const char *web_host, | 398 | const std::string& web_host, |
404 | const char *local_web_host, | 399 | const std::string& local_web_host, |
405 | const char *host_name) | 400 | const std::string& host_name) |
406 | : LLAssetStorage(msg, xfer, vfs, upstream_host) | 401 | : LLAssetStorage(msg, xfer, vfs, upstream_host) |
407 | { | 402 | { |
408 | _init(web_host, local_web_host, host_name); | 403 | _init(web_host, local_web_host, host_name); |
@@ -410,15 +405,15 @@ LLHTTPAssetStorage::LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer | |||
410 | 405 | ||
411 | LLHTTPAssetStorage::LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, | 406 | LLHTTPAssetStorage::LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, |
412 | LLVFS *vfs, | 407 | LLVFS *vfs, |
413 | const char *web_host, | 408 | const std::string& web_host, |
414 | const char *local_web_host, | 409 | const std::string& local_web_host, |
415 | const char *host_name) | 410 | const std::string& host_name) |
416 | : LLAssetStorage(msg, xfer, vfs) | 411 | : LLAssetStorage(msg, xfer, vfs) |
417 | { | 412 | { |
418 | _init(web_host, local_web_host, host_name); | 413 | _init(web_host, local_web_host, host_name); |
419 | } | 414 | } |
420 | 415 | ||
421 | void LLHTTPAssetStorage::_init(const char *web_host, const char *local_web_host, const char* host_name) | 416 | void LLHTTPAssetStorage::_init(const std::string& web_host, const std::string& local_web_host, const std::string& host_name) |
422 | { | 417 | { |
423 | mBaseURL = web_host; | 418 | mBaseURL = web_host; |
424 | mLocalBaseURL = local_web_host; | 419 | mLocalBaseURL = local_web_host; |
@@ -470,7 +465,7 @@ void LLHTTPAssetStorage::storeAssetData( | |||
470 | { | 465 | { |
471 | message = "Added to upload queue"; | 466 | message = "Added to upload queue"; |
472 | } | 467 | } |
473 | reportMetric( uuid, type, NULL, requesting_agent_id, size, MR_OKAY, __FILE__, __LINE__, message ); | 468 | reportMetric( uuid, type, LLStringUtil::null, requesting_agent_id, size, MR_OKAY, __FILE__, __LINE__, message ); |
474 | 469 | ||
475 | // this will get picked up and transmitted in checkForTimeouts | 470 | // this will get picked up and transmitted in checkForTimeouts |
476 | if(store_local) | 471 | if(store_local) |
@@ -492,7 +487,7 @@ void LLHTTPAssetStorage::storeAssetData( | |||
492 | if (callback) | 487 | if (callback) |
493 | { | 488 | { |
494 | // LLAssetStorage metric: Zero size VFS | 489 | // LLAssetStorage metric: Zero size VFS |
495 | reportMetric( uuid, type, NULL, requesting_agent_id, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file didn't exist or was zero length (VFS - can't tell which)" ); | 490 | reportMetric( uuid, type, LLStringUtil::null, requesting_agent_id, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file didn't exist or was zero length (VFS - can't tell which)" ); |
496 | callback(uuid, user_data, LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE, LL_EXSTAT_NONEXISTENT_FILE); | 491 | callback(uuid, user_data, LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE, LL_EXSTAT_NONEXISTENT_FILE); |
497 | } | 492 | } |
498 | } | 493 | } |
@@ -500,7 +495,7 @@ void LLHTTPAssetStorage::storeAssetData( | |||
500 | 495 | ||
501 | // virtual | 496 | // virtual |
502 | void LLHTTPAssetStorage::storeAssetData( | 497 | void LLHTTPAssetStorage::storeAssetData( |
503 | const char* filename, | 498 | const std::string& filename, |
504 | const LLUUID& asset_id, | 499 | const LLUUID& asset_id, |
505 | LLAssetType::EType asset_type, | 500 | LLAssetType::EType asset_type, |
506 | LLStoreAssetCallback callback, | 501 | LLStoreAssetCallback callback, |
@@ -597,7 +592,7 @@ LLSD LLHTTPAssetStorage::getPendingDetails(LLAssetStorage::ERequestType rt, | |||
597 | LLSD& pending = sd["requests"][i]; | 592 | LLSD& pending = sd["requests"][i]; |
598 | // See if this pending request is running. | 593 | // See if this pending request is running. |
599 | const LLAssetRequest* req = findRequest(running, | 594 | const LLAssetRequest* req = findRequest(running, |
600 | LLAssetType::lookup(pending["type"].asString().c_str()), | 595 | LLAssetType::lookup(pending["type"].asString()), |
601 | pending["asset_id"]); | 596 | pending["asset_id"]); |
602 | if (req) | 597 | if (req) |
603 | { | 598 | { |
@@ -768,11 +763,11 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
768 | // Setup this curl download request | 763 | // Setup this curl download request |
769 | // We need to generate a new request here | 764 | // We need to generate a new request here |
770 | // since the one in the list could go away | 765 | // since the one in the list could go away |
771 | char tmp_url[MAX_STRING]; /*Flawfinder: ignore*/ | 766 | std::string tmp_url; |
772 | char uuid_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ | 767 | std::string uuid_str; |
773 | req->getUUID().toString(uuid_str); | 768 | req->getUUID().toString(uuid_str); |
774 | std::string base_url = getBaseURL(req->getUUID(), req->getType()); | 769 | std::string base_url = getBaseURL(req->getUUID(), req->getType()); |
775 | snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", base_url.c_str() , uuid_str, LLAssetType::lookup(req->getType())); /* Flawfinder: ignore */ | 770 | tmp_url = llformat("%s/%36s.%s", base_url.c_str() , uuid_str.c_str(), LLAssetType::lookup(req->getType())); |
776 | 771 | ||
777 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), | 772 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), |
778 | req->getType(), RT_DOWNLOAD, tmp_url, mCurlMultiHandle); | 773 | req->getType(), RT_DOWNLOAD, tmp_url, mCurlMultiHandle); |
@@ -805,12 +800,11 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
805 | 800 | ||
806 | bool do_compress = req->getType() == LLAssetType::AT_OBJECT; | 801 | bool do_compress = req->getType() == LLAssetType::AT_OBJECT; |
807 | 802 | ||
808 | char tmp_url[MAX_STRING];/*Flawfinder: ignore*/ | 803 | std::string tmp_url; |
809 | char uuid_str[UUID_STR_LENGTH];/*Flawfinder: ignore*/ | 804 | std::string uuid_str; |
810 | req->getUUID().toString(uuid_str); | 805 | req->getUUID().toString(uuid_str); |
811 | snprintf(tmp_url, sizeof(tmp_url), /* Flawfinder: ignore */ | 806 | tmp_url = mBaseURL + "/" + uuid_str + "." + LLAssetType::lookup(req->getType()); |
812 | do_compress ? "%s/%s.%s.gz" : "%s/%s.%s", | 807 | if (do_compress) tmp_url += ".gz"; |
813 | mBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); | ||
814 | 808 | ||
815 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), | 809 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), |
816 | req->getType(), RT_UPLOAD, tmp_url, mCurlMultiHandle); | 810 | req->getType(), RT_UPLOAD, tmp_url, mCurlMultiHandle); |
@@ -876,12 +870,12 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
876 | // setup this curl upload request | 870 | // setup this curl upload request |
877 | LLVFile file(mVFS, req->getUUID(), req->getType()); | 871 | LLVFile file(mVFS, req->getUUID(), req->getType()); |
878 | 872 | ||
879 | char tmp_url[MAX_STRING]; /*Flawfinder: ignore*/ | 873 | std::string tmp_url; |
880 | char uuid_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ | 874 | std::string uuid_str; |
881 | req->getUUID().toString(uuid_str); | 875 | req->getUUID().toString(uuid_str); |
882 | 876 | ||
883 | // KLW - All temporary uploads are saved locally "http://localhost:12041/asset" | 877 | // KLW - All temporary uploads are saved locally "http://localhost:12041/asset" |
884 | snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", mLocalBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); /* Flawfinder: ignore */ | 878 | tmp_url = llformat("%s/%36s.%s", mLocalBaseURL.c_str(), uuid_str.c_str(), LLAssetType::lookup(req->getType())); |
885 | 879 | ||
886 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), | 880 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), |
887 | req->getType(), RT_LOCALUPLOAD, tmp_url, mCurlMultiHandle); | 881 | req->getType(), RT_LOCALUPLOAD, tmp_url, mCurlMultiHandle); |
@@ -1160,7 +1154,7 @@ size_t LLHTTPAssetStorage::nullOutputCallback(void *data, size_t size, size_t nm | |||
1160 | 1154 | ||
1161 | // blocking asset fetch which bypasses the VFS | 1155 | // blocking asset fetch which bypasses the VFS |
1162 | // this is a very limited function for use by the simstate loader and other one-offs | 1156 | // this is a very limited function for use by the simstate loader and other one-offs |
1163 | S32 LLHTTPAssetStorage::getURLToFile(const LLUUID& uuid, LLAssetType::EType asset_type, const LLString &url, const char *filename, progress_callback callback, void *userdata) | 1157 | S32 LLHTTPAssetStorage::getURLToFile(const LLUUID& uuid, LLAssetType::EType asset_type, const std::string &url, const std::string& filename, progress_callback callback, void *userdata) |
1164 | { | 1158 | { |
1165 | // *NOTE: There is no guarantee that the uuid and the asset_type match | 1159 | // *NOTE: There is no guarantee that the uuid and the asset_type match |
1166 | // - not that it matters. - Doug | 1160 | // - not that it matters. - Doug |
@@ -1174,7 +1168,7 @@ S32 LLHTTPAssetStorage::getURLToFile(const LLUUID& uuid, LLAssetType::EType asse | |||
1174 | } | 1168 | } |
1175 | 1169 | ||
1176 | // make sure we use the normal curl setup, even though we don't really need a request object | 1170 | // make sure we use the normal curl setup, even though we don't really need a request object |
1177 | LLHTTPAssetRequest req(this, uuid, asset_type, RT_DOWNLOAD, url.c_str(), mCurlMultiHandle); | 1171 | LLHTTPAssetRequest req(this, uuid, asset_type, RT_DOWNLOAD, url, mCurlMultiHandle); |
1178 | req.mFP = fp; | 1172 | req.mFP = fp; |
1179 | 1173 | ||
1180 | req.setupCurlHandle(); | 1174 | req.setupCurlHandle(); |