From 9ea7d347c13c816e3f9c1a39ce3ea06f87a30f61 Mon Sep 17 00:00:00 2001 From: Fireball Wayne Date: Sun, 12 Mar 2017 01:15:40 -0500 Subject: [PATCH] Remoteiso better http header detection --- UI/RemoteISOScreen.cpp | 25 +++++++++++++++++++++---- UI/RemoteISOScreen.h | 1 - 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 61d66cc61a..d591450335 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -285,7 +285,22 @@ static bool LoadGameList(const std::string &host, int port, std::vector items; result.TakeAll(&listing); - if (startsWith(responseHeaders[1],"Content-Type: text/plain")) { + std::string contentType; + for (const std::string &header : responseHeaders) { + if (startsWithNoCase(header, "Content-Type:")) { + contentType = header.substr(strlen("Content-Type:")); + // Strip any whitespace (TODO: maybe move this to stringutil?) + contentType.erase(0, contentType.find_first_not_of(" \t\r\n")); + contentType.erase(contentType.find_last_not_of(" \t\r\n") + 1); + } + } + + // TODO: Technically, "TExt/hTml ; chaRSet = Utf8" should pass, but "text/htmlese" should not. + // But unlikely that'll be an issue. + bool parseHtml = startsWithNoCase(contentType, "text/html"); + bool parseText = startsWithNoCase(contentType, "text/plain"); + + if (parseText) { //ppsspp server SplitString(listing, '\n', items); for (const std::string &item : items) { @@ -297,7 +312,7 @@ static bool LoadGameList(const std::string &host, int port, std::vectorAdd(new TextView(sy->T("RemoteISODesc", "Games in your recent list will be shared"), new LinearLayoutParams(Margins(12, 5, 0, 5)))); leftColumnItems->Add(new TextView(sy->T("RemoteISOWifi", "Note: Connect both devices to the same wifi"), new LinearLayoutParams(Margins(12, 5, 0, 5)))); - // TODO: Could display server address for manual entry. - rightColumnItems->SetSpacing(0.0f); Choice *browseChoice = new Choice(sy->T("Browse Games")); rightColumnItems->Add(browseChoice)->OnClick.Handle(this, &RemoteISOScreen::HandleBrowse); diff --git a/UI/RemoteISOScreen.h b/UI/RemoteISOScreen.h index 5effe8c34d..9ceb5c0877 100644 --- a/UI/RemoteISOScreen.h +++ b/UI/RemoteISOScreen.h @@ -87,7 +87,6 @@ protected: class RemoteISOSettingsScreen : public UIScreenWithBackground { public: -// RemoteISOSettingsScreen(); protected: void CreateViews() override;