Skip to content
Snippets Groups Projects
Commit 5e953328 authored by Odilitime's avatar Odilitime
Browse files

updates from URI integration

parent 8813aa4e
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,7 @@ namespace { ...@@ -19,7 +19,7 @@ namespace {
}; };
bool isOnlineResource(URL const& url) { bool isOnlineResource(URL const& url) {
return url.protocol != "file"; return url.scheme != "file";
} }
} }
...@@ -44,7 +44,7 @@ WebResource getWebResource(URL const& url) { ...@@ -44,7 +44,7 @@ WebResource getWebResource(URL const& url) {
} }
WebResource getLocalWebResource(URL const& url) { WebResource getLocalWebResource(URL const& url) {
std::string fileExtension = getFilenameExtension(url.document); std::string fileExtension = getFilenameExtension(url.path);
if (fileExtension.length() == 0) { if (fileExtension.length() == 0) {
return WebResource(ResourceType::INVALID, return WebResource(ResourceType::INVALID,
"Could not find any file extension"); "Could not find any file extension");
...@@ -61,7 +61,7 @@ WebResource getLocalWebResource(URL const& url) { ...@@ -61,7 +61,7 @@ WebResource getLocalWebResource(URL const& url) {
"Local file with extension " + fileExtension + " is not supported. Did you forget a http://?"); "Local file with extension " + fileExtension + " is not supported. Did you forget a http://?");
} }
std::ifstream in(url.document, std::ios::in | std::ios::binary); std::ifstream in(url.path, std::ios::in | std::ios::binary);
if (in) { if (in) {
// There exists more efficient ways of doing this, but it works for the // There exists more efficient ways of doing this, but it works for the
// time being. // time being.
...@@ -72,20 +72,22 @@ WebResource getLocalWebResource(URL const& url) { ...@@ -72,20 +72,22 @@ WebResource getLocalWebResource(URL const& url) {
} }
return WebResource(ResourceType::INVALID, return WebResource(ResourceType::INVALID,
"Could not open file " + url.document); "Could not open file " + url.path);
} }
//WebResource getOnlineWebResource(URL const& url) { WebResource getOnlineWebResource(URL const& url) {
// HTTPRequest request (url.host, url.document); std::shared_ptr<URL> uri=std::make_shared<URL>(url);
WebResource getOnlineWebResource(std::string url) {
std::shared_ptr<URI> uri = parseUri(url);
HTTPRequest request (uri); HTTPRequest request (uri);
//window->currentURL=url;
//request->sendRequest(handleRequest);
WebResource returnRes; WebResource returnRes;
std::string redirectLocation = ""; std::string redirectLocation = "";
request.sendRequest([&](HTTPResponse const& response){ request.sendRequest([&](HTTPResponse const& response){
logDebug() << "getOnlineWebResource request.sendRequest" << std::endl;
if (response.statusCode == 301) { if (response.statusCode == 301) {
std::string location; std::string location;
if (response.properties.find("Location")==response.properties.end()) { if (response.properties.find("Location")==response.properties.end()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment