|
@@ -81,19 +81,26 @@ class TracimWsgiDavDebugFilter(BaseMiddleware):
|
81
|
81
|
# "locks: 15",
|
82
|
82
|
]
|
83
|
83
|
|
84
|
|
- if self._config.get('dump_requests'):
|
85
|
|
- # Monkey patching
|
86
|
|
- old_parseXmlBody = util.parseXmlBody
|
87
|
|
- def new_parseXmlBody(environ, allowEmpty=False):
|
88
|
|
- xml = old_parseXmlBody(environ, allowEmpty)
|
89
|
|
- self._dump_request(environ, xml)
|
90
|
|
- return xml
|
91
|
|
- util.parseXmlBody = new_parseXmlBody
|
|
84
|
+ self.last_request_time = '__NOT_SET__'
|
|
85
|
+
|
|
86
|
+ # We disable request content dump for moment
|
|
87
|
+ # if self._config.get('dump_requests'):
|
|
88
|
+ # # Monkey patching
|
|
89
|
+ # old_parseXmlBody = util.parseXmlBody
|
|
90
|
+ # def new_parseXmlBody(environ, allowEmpty=False):
|
|
91
|
+ # xml = old_parseXmlBody(environ, allowEmpty)
|
|
92
|
+ # self._dump_request(environ, xml)
|
|
93
|
+ # return xml
|
|
94
|
+ # util.parseXmlBody = new_parseXmlBody
|
92
|
95
|
|
93
|
96
|
def __call__(self, environ, start_response):
|
94
|
97
|
""""""
|
95
|
98
|
# srvcfg = environ["wsgidav.config"]
|
96
|
99
|
verbose = self._config.get("verbose", 2)
|
|
100
|
+ self.last_request_time = '{0}_{1}'.format(
|
|
101
|
+ datetime.utcnow().strftime('%Y-%m-%d_%H-%M-%S'),
|
|
102
|
+ int(round(time.time() * 1000)),
|
|
103
|
+ )
|
97
|
104
|
|
98
|
105
|
method = environ["REQUEST_METHOD"]
|
99
|
106
|
|
|
@@ -155,6 +162,7 @@ class TracimWsgiDavDebugFilter(BaseMiddleware):
|
155
|
162
|
if k == k.upper():
|
156
|
163
|
print("%20s: '%s'" % (k, v), file=self.out)
|
157
|
164
|
print("\n", file=self.out)
|
|
165
|
+ self._dump_request(environ, xml=None)
|
158
|
166
|
|
159
|
167
|
# Intercept start_response
|
160
|
168
|
#
|
|
@@ -233,14 +241,15 @@ class TracimWsgiDavDebugFilter(BaseMiddleware):
|
233
|
241
|
os.makedirs(dump_to_path, exist_ok=True)
|
234
|
242
|
dump_file = '{0}/{1}_RESPONSE_{2}.yml'.format(
|
235
|
243
|
dump_to_path,
|
236
|
|
- '{0}_{1}'.format(
|
237
|
|
- datetime.utcnow().strftime('%Y-%m-%d_%H-%M-%S'),
|
238
|
|
- int(round(time.time() * 1000)),
|
239
|
|
- ),
|
|
244
|
+ self.last_request_time,
|
240
|
245
|
sub_app_start_response.status[0:3],
|
241
|
246
|
)
|
242
|
247
|
with open(dump_file, 'w+') as f:
|
243
|
248
|
dump_content = dict()
|
|
249
|
+ headers = {}
|
|
250
|
+ for header_tuple in sub_app_start_response.response_headers:
|
|
251
|
+ headers[header_tuple[0]] = header_tuple[1]
|
|
252
|
+ dump_content['headers'] = headers
|
244
|
253
|
if isinstance(drb, str):
|
245
|
254
|
dump_content['content'] = drb.replace('PROPFIND XML response body:\n', '')
|
246
|
255
|
|
|
@@ -254,16 +263,13 @@ class TracimWsgiDavDebugFilter(BaseMiddleware):
|
254
|
263
|
os.makedirs(dump_to_path, exist_ok=True)
|
255
|
264
|
dump_file = '{0}/{1}_REQUEST_{2}.yml'.format(
|
256
|
265
|
dump_to_path,
|
257
|
|
- '{0}_{1}'.format(
|
258
|
|
- datetime.utcnow().strftime('%Y-%m-%d_%H-%M-%S'),
|
259
|
|
- int(round(time.time() * 1000)),
|
260
|
|
- ),
|
|
266
|
+ self.last_request_time,
|
261
|
267
|
environ['REQUEST_METHOD'],
|
262
|
268
|
)
|
263
|
269
|
with open(dump_file, 'w+') as f:
|
264
|
270
|
dump_content = dict()
|
265
|
|
- dump_content['path'] = environ['PATH_INFO']
|
266
|
|
- dump_content['Authorization'] = environ['HTTP_AUTHORIZATION']
|
|
271
|
+ dump_content['path'] = environ.get('PATH_INFO', '')
|
|
272
|
+ dump_content['Authorization'] = environ.get('HTTP_AUTHORIZATION', '')
|
267
|
273
|
if xml:
|
268
|
274
|
dump_content['content'] = ElementTree.tostring(xml, 'utf-8')
|
269
|
275
|
|