正在显示
9 个修改的文件
包含
68 行增加
和
20 行删除
... | ... | @@ -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 | ############################################################# | ... | ... |
... | ... | @@ -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; | ... | ... |
请
注册
或
登录
后发表评论