Skip to content

Commit

Permalink
Merge pull request #64 from aoleg94/master
Browse files Browse the repository at this point in the history
improve http support
  • Loading branch information
darkxex authored Jun 28, 2022
2 parents 68b984a + bde4e6b commit 3c300a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 3 additions & 3 deletions source/UI/networkBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ namespace Windows {

}else if (thislist[n].type == FS::FileEntryType::File){

std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + std::string("/") + httpdir->getCurrPath() + thislist[n].name;
std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + (thisurl.port.empty() ? std::string() : ':' + thisurl.port) + std::string("/") + httpdir->getCurrPath() + thislist[n].name;
std::string checkitemid = "##check" + std::to_string(n);
ImGui::SetCursorPos({ImGui::GetCursorPos().x, ImGui::GetCursorPos().y + (40 - ImGui::GetFont()->FontSize - ImGui::GetStyle().FramePadding.y * 2) / 2});
if(ImGui::Checkbox(checkitemid.c_str(), httpdir->checked(n))){
Expand Down Expand Up @@ -219,7 +219,7 @@ namespace Windows {
}else if (thislist[n].type == FS::FileEntryType::File){

urlschema thisurl = Utility::parseUrl(httpdir->getUrl());
std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + std::string("/") + httpdir->getCurrPath() + thislist[n].name;
std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + (thisurl.port.empty() ? std::string() : ':' + thisurl.port) + std::string("/") + httpdir->getCurrPath() + thislist[n].name;
item.laststate = item.state;
playlist->clearPlaylist();
httpdir->clearChecked();
Expand All @@ -240,7 +240,7 @@ namespace Windows {
ImVec4 textcolor = colors[ImGuiCol_Text];

if(sqlitedb != nullptr){
std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + std::string("/") + httpdir->getCurrPath() + thislist[n].name;
std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + (thisurl.port.empty() ? std::string() : ':' + thisurl.port) + std::string("/") + httpdir->getCurrPath() + thislist[n].name;
int dbfilestatus = sqlitedb->getFileDbStatus(openurl);
if(dbfilestatus == 2){
textcolor = ImVec4(0.0f,1.0f,0.0f,1.0f);
Expand Down
10 changes: 3 additions & 7 deletions source/remotefs/HTTPDir/HTTPDir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,14 @@ HTTPDir::~HTTPDir(){
void HTTPDir::DirList(std::string path,const std::vector<std::string> &extensions){
currentlist.clear();
urlschema thisurl = Utility::parseUrl(url);
std::string geturl = thisurl.scheme + std::string("://") + thisurl.server + std::string("/") + path;
std::string geturl = thisurl.scheme + std::string("://") + 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;
std::smatch sm;
currentpath = path;
std::regex rgxdirlist("<h1>Index of");
if(!regex_search(s, sm, rgxdirlist)){
return;
}

std::regex rgxlinks("<tr>.*?<td><a href=\"(.*?)\".*?>(?!Parent Directory)(.*?)<\/a>.*?<\/td><\/tr>");
std::regex rgxlinks("<a href=\"(.*?)\".*?>(?!Parent Directory)(.*?)<\/a>");

while (regex_search(s, sm, rgxlinks))
{
Expand Down Expand Up @@ -137,4 +133,4 @@ void HTTPDir::backDir(){
currentpath = currentpath.substr(0, currentpath.find_last_of("\\/")+1);
}

#endif
#endif

0 comments on commit 3c300a7

Please sign in to comment.