From 344cf5aa862c55a94530628b913d11e190b29508 Mon Sep 17 00:00:00 2001 From: lijing Date: Mon, 31 Jul 2017 00:12:49 +0800 Subject: [PATCH] add some annotation to the code. --- Main/ghttp.cpp | 10 ++++++++-- Server/web/index.js | 2 ++ Server/web/openkg.html | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Main/ghttp.cpp b/Main/ghttp.cpp index 80c8969..4145c73 100644 --- a/Main/ghttp.cpp +++ b/Main/ghttp.cpp @@ -514,6 +514,7 @@ void delete_result(const HttpServer& server, const shared_ptrtellg(); ifs->seekg(0, ios::beg); - + //!Notice: remember to set the Content-Disposition and the Content-type to let the browser to download. *response << "HTTP/1.1 200 OK\r\n" << "Content-Length: " << length << "\r\n"; *response << "Content-Disposition: attachment; filename=sparql.txt" << "\r\n"; *response << "Content-Type: application/octet-stream" << "\r\n\r\n"; @@ -841,7 +842,10 @@ bool query_handler(const HttpServer& server, const shared_ptrseekg(0, ios::beg); *response << "HTTP/1.1 200 OK\r\n" << cache_control << etag << "Content-Length: " << length << "\r\n"; + //!Notice: IE need to declare the Content-type of the response, if not the browser will not show the result with an unknow format. + //it works well in Firefox and Chrome if you don't declare the Content-type, but in IE the css file will be ignored because of unmatched MIME type, then the web page will show in a form without css style and it looks ugly. if(extName == ".html") *response << "Content-Type: text/html" << "\r\n\r\n"; else if(extName == ".js") diff --git a/Server/web/index.js b/Server/web/index.js index 82925be..e386161 100644 --- a/Server/web/index.js +++ b/Server/web/index.js @@ -112,6 +112,8 @@ function query(dp) { var tmp2 = "?operation=delete&filepath=" + fileName; var request2 = escape(tmp2); var element2 = document.getElementById("back"); + //!Notice: element2 is a "" tag, and it has two actions, href and onclick, be careful with the executing order of these two actions. + //in this case, we use a call-back function to prevent strange things. we return to the origin web page after the request to delete file returns successfully. element2.onclick = function(){ $.get(request2, function(data, status){ //alert("delete return"); diff --git a/Server/web/openkg.html b/Server/web/openkg.html index 0bae4a7..ce972eb 100644 --- a/Server/web/openkg.html +++ b/Server/web/openkg.html @@ -51,10 +51,11 @@
  • breastcancer4.gstore-pku.com
  • Clinga
  • clinga.gstore-pku.com
  • -
  • Person
  • +