From f5db11640f09120a39607b68719f71a1c555fed8 Mon Sep 17 00:00:00 2001 From: Anthony Garcia Date: Sat, 6 Jan 2024 18:05:35 +0800 Subject: [PATCH] [fix] added username and password in url for remote http --- source/remotefs/HTTPDir/HTTPDir.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/remotefs/HTTPDir/HTTPDir.cpp b/source/remotefs/HTTPDir/HTTPDir.cpp index ad43e6d..d2228c2 100644 --- a/source/remotefs/HTTPDir/HTTPDir.cpp +++ b/source/remotefs/HTTPDir/HTTPDir.cpp @@ -60,6 +60,12 @@ void HTTPDir::DirList(std::string path,const std::vector &extension currentlist.clear(); urlschema thisurl = Utility::parseUrl(url); std::string geturl = thisurl.scheme + std::string("://") + thisurl.server + (thisurl.port.empty() ? std::string() : ':' + thisurl.port) + std::string("/") + path; + if (thisurl.user != NULL && thisurl.pass != NULL){ + std::string geturl = thisurl.scheme + std::string("://") + thisurl.user + ":" + thisurl.pass + "@" + thisurl.server + (thisurl.port.empty() ? std::string() : ':' + thisurl.port) + std::string("/") + path; + } + else if (thisurl.user != NULL){ + std::string geturl = thisurl.scheme + std::string("://") + thisurl.user + "@" + thisurl.server + (thisurl.port.empty() ? std::string() : ':' + thisurl.port) + std::string("/") + path; + } HTTPMemoryStruct *chunk = (HTTPMemoryStruct *)malloc(sizeof(HTTPMemoryStruct)); curlDownload((char *)geturl.c_str(),chunk); std::string s = chunk->memory;