提交 39118fa342dd45f745951206ddc7df356313eb71

作者 LJH 李佳桓
1 个父辈 a073644d

ljh

... ... @@ -39,7 +39,6 @@ SET (DMAP_SERVER_SRCS
39 39 python/dmpserverwrapper.cpp
40 40 dmphttpbase.cpp
41 41 dmphttputils.cpp
42   -
43 42 )
44 43
45 44 SET (DMAP_SERVER_HDRS
... ... @@ -71,7 +70,6 @@ SET (DMAP_SERVER_HDRS
71 70 python/dmppythonutils.h
72 71 dmphttpbase.h
73 72 dmphttputils.h
74   -
75 73 )
76 74
77 75 #############################################################
... ...
... ... @@ -49,7 +49,8 @@ public:
49 49 {
50 50 return;
51 51 }
52   -
  52 +
  53 +
53 54 DmpSpServerRequest dmpRequest(request);
54 55 DmpSpServerResponse dmpResponse(response);
55 56 pDmpServer->HandleRequest(dmpRequest, dmpResponse);
... ...
... ... @@ -20,7 +20,7 @@
20 20 #include "dmpserverregistry.h"
21 21
22 22
23   -#define URI_RELOAD ("/API/Service/TileService/Reload") //加载已注册服务接口
  23 +#define URI_RELOAD ("/API/Service/Reload") //加载已注册服务接口
24 24 class SERVER_EXPORT DmpServerManager
25 25 {
26 26 public:
... ...
... ... @@ -16,6 +16,8 @@
16 16 // #include <boost/algorithm/string.hpp>
17 17 #include "dmplogger.h"
18 18
  19 +
  20 +
19 21 DmpServerRequest::DmpServerRequest()
20 22 {
21 23 isRestful_ = false;
... ...
... ... @@ -39,19 +39,21 @@ DmpSpServerRequest::DmpSpServerRequest(SP_HttpRequest* request)
39 39 }
40 40
41 41 //获取querystring
42   - std::string url(request->getURL());
43   - //std::string deurl=Percent::decode( url);
44   - std::string::size_type pos = url.find("?");
  42 + std::string url(request->getURL());
  43 + std::string deurl;
  44 + this->UrlDecode(url,deurl);
  45 +
  46 + std::string::size_type pos = deurl.find("?");
45 47 if (pos != std::string::npos) {
46   - std::string path = url.substr(0, pos);
  48 + std::string path = deurl.substr(0, pos);
47 49 setPath(path);
48 50 std::string queryString;
49   - queryString = url.substr(pos+1,url.length());
  51 + queryString = deurl.substr(pos+1,deurl.length());
50 52 setQuery(queryString);
51 53 }
52 54 else {
53 55 isRestful_ = true;
54   - setPath(url);
  56 + setPath(deurl);
55 57 }
56 58
57 59 // for(int i=0; i< request->getParamCount(); i++) {
... ... @@ -71,4 +73,50 @@ const void * DmpSpServerRequest::GetData() const
71 73 int DmpSpServerRequest::GetDataLength() const
72 74 {
73 75 return dataLen_;
  76 +}
  77 +bool DmpSpServerRequest::UrlDecode(const std::string& src, std::string& dst)
  78 +{
  79 + if(src.size() == 0)
  80 + return false;
  81 + int hex = 0;
  82 + for (size_t i = 0; i < src.length(); ++i)
  83 + {
  84 + switch (src[i])
  85 + {
  86 + case '+':
  87 + dst += ' ';
  88 + break;
  89 + case '%':
  90 + {
  91 + if (isxdigit(src[i + 1]) && isxdigit(src[i + 2]))
  92 + {
  93 + std::string hexStr = src.substr(i + 1, 2);
  94 + hex = strtol(hexStr.c_str(), 0, 16);
  95 + //字母和数字[0-9a-zA-Z]、一些特殊符号[$-_.+!*'(),] 、以及某些保留字[$&+,/:;=?@]
  96 + //可以不经过编码直接用于URL
  97 + if (!((hex >= 48 && hex <= 57) || //0-9
  98 + (hex >=97 && hex <= 122) || //a-z
  99 + (hex >=65 && hex <= 90) || //A-Z
  100 + //一些特殊符号及保留字[$-_.+!*'(),] [$&+,/:;=?@]
  101 + hex == 0x21 || hex == 0x24 || hex == 0x26 || hex == 0x27 || hex == 0x28 || hex == 0x29
  102 + || hex == 0x2a || hex == 0x2b|| hex == 0x2c || hex == 0x2d || hex == 0x2e || hex == 0x2f
  103 + || hex == 0x3A || hex == 0x3B|| hex == 0x3D || hex == 0x3f || hex == 0x40 || hex == 0x5f
  104 + ))
  105 + {
  106 + dst += char(hex);
  107 + i += 2;
  108 + }
  109 + else
  110 + dst += '%';
  111 + }
  112 + else
  113 + dst += '%';
  114 + }
  115 + break;
  116 + default:
  117 + dst += src[i];
  118 + break;
  119 + }
  120 + }
  121 + return true;
74 122 }
\ No newline at end of file
... ...
... ... @@ -23,6 +23,7 @@ public:
23 23 DmpSpServerRequest(SP_HttpRequest* request);
24 24 const void * GetData() const override;
25 25 int GetDataLength() const override;
  26 + bool UrlDecode(const std::string& src, std::string& dst);
26 27 private:
27 28 const void* data_;
28 29 int dataLen_;
... ...
... ... @@ -134,16 +134,12 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const
134 134 break;
135 135 }
136 136
137   - context.response()->write("{\"status\":\""+std::to_string(flag)+"\",\"url\":\""+url+"\",\"message\":\"Pulish service successful!\"}");
138 137 // std::string projData;
139 138 // DmpServerUtils::Base64Decode(project, &projData);
140   - // context.response()->removeHeader("Content-Type");
141   - // context.response()->setHeader("Content-Type", "text/xml;charset=utf-8");
142   - // context.response()->write(projData);
143   -
144   -
145   -
146   -
  139 + context.response()->removeHeader("Content-Type");
  140 + context.response()->setHeader("Content-Type", "text/xml;charset=utf-8");
  141 + // context.response()->write(projData);
  142 + context.response()->write("{\"status\":\""+std::to_string(flag)+"\",\"url\":\""+url+"\",\"message\":\"Pulish service successful!\"}");
147 143 }
148 144 else
149 145 {
... ...
... ... @@ -34,7 +34,8 @@ public:
34 34 ~DmpMapServer();
35 35 std::string name() const override { return std::string("MapServer");}
36 36 std::string alias() const override { return std::string("矢量地图服务");}
37   - std::string path() const override { return std::string("^/DMap/Services/?([\\w./]*)/MapServer/([\\w]+)"); }
  37 + //std::string path() const override { return std::string("^/DMap/Services/?([\\w./]*)/MapServer/([\\w]+)"); }
  38 + std::string path() const override { return std::string("^/DMap/Services/?([\\w\\W./]*)/MapServer/([\\w]+)"); }
38 39 std::string capability() const override;
39 40 void executeRequest(DmpServerRequest &request, DmpServerResponse &response) override;
40 41 bool publish(const std::string &serviceName, const std::string &title, unsigned int capability, const DmpProject &project) override;
... ...
... ... @@ -35,7 +35,8 @@ public:
35 35 ~DmpTileServer();
36 36 std::string name() const override { return std::string("TileServer");}
37 37 std::string alias() const override { return std::string("瓦片服务");}
38   - std::string path() const override { return std::string("^/DMap/Services/?([\\w./]*)/TileServer/([\\w.]+)([\\w./]*)"); }
  38 + //std::string path() const override { return std::string("^/DMap/Services/?([\\w./]*)/TileServer/([\\w.]+)([\\w./]*)"); }
  39 + std::string path() const override { return std::string("^/DMap/Services/?([\\w\\W./]*)/TileServer/([\\w.]+)([\\w./]*)"); }
39 40 std::string capability() const override;
40 41 void executeRequest(DmpServerRequest &request, DmpServerResponse &response) override;
41 42 bool publish(const std::string &serviceName, const std::string &title, unsigned int capability, const DmpProject &project) override;
... ...
注册登录 后发表评论