正在显示
1 个修改的文件
包含
62 行增加
和
0 行删除
src/python/plugins/debug/debug.py
0 → 100644
1 | +# coding=utf-8 | |
2 | +"""" Simple DEBUG SERVICE plugin | |
3 | + | |
4 | +http://localhost:8080/cgi-bin/qgis_mapserv.cgi?SERVICE=DEBUG | |
5 | + | |
6 | +.. note:: This program is free software; you can redistribute it and/or modify | |
7 | + it under the terms of the GNU General Public License as published by | |
8 | + the Free Software Foundation; either version 2 of the License, or | |
9 | + (at your option) any later version. | |
10 | + | |
11 | +""" | |
12 | + | |
13 | +__author__ = 'wanzhongping' | |
14 | +__date__ = '2021-04-20' | |
15 | +__copyright__ = 'chinadci' | |
16 | + | |
17 | + | |
18 | +import os | |
19 | +from dmap_server import * | |
20 | + | |
21 | + | |
22 | +class DebugFilter(DmpServerFilter): | |
23 | + | |
24 | + def request_ready(self): | |
25 | + handler = self.server_interface().request_handler() | |
26 | + params = handler.parameters() | |
27 | + if len(params) == 0: | |
28 | + return | |
29 | + if 'DEBUG' in params: | |
30 | + handler.set_parameter('SERVICE', 'DEBUG') | |
31 | + print("request_ready") | |
32 | + | |
33 | + def response_complete(self): | |
34 | + handler = self.server_interface().request_handler() | |
35 | + params = handler.parameters() | |
36 | + if len(params) == 0: | |
37 | + return | |
38 | + if params['service'] != 'DEBUG': | |
39 | + return | |
40 | + | |
41 | + headers_dict = handler.request_headers() | |
42 | + handler.clear() | |
43 | + handler.set_response_header('Status', '200 Ok') | |
44 | + handler.append_body(b'<h1>Params</h1>') | |
45 | + for param in params: | |
46 | + handler.append_body(('<p><b>%s</b> "%s"</p>' % (param.key(), param.data())).encode('utf8')) | |
47 | + # handler.append_body('<p><b>%s</b> "%s"</p>' % (param.key(), param.data())) | |
48 | + | |
49 | + handler.append_body('<h1>Headers</h1>'.encode('utf8')) | |
50 | + for header in headers_dict: | |
51 | + handler.append_body(('<p><b>%s</b> "%s"</p>' % (header.key(), header.data())).encode('utf8')) | |
52 | + print("response_complete") | |
53 | + | |
54 | + | |
55 | +class Debug: | |
56 | + | |
57 | + def __init__(self, serverIface): | |
58 | + # Save reference to the DMap server interface | |
59 | + # Higher priority | |
60 | + self.debugFilter = DebugFilter(serverIface) | |
61 | + serverIface.register_filter(self.debugFilter, 10) | |
62 | + | ... | ... |
请
注册
或
登录
后发表评论