Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

HH-33539 httpreq class patching to remove body logging from POST reqs

  • Loading branch information...
commit 6b912437f59b4a81b457344163021c335642b9d1 1 parent cd57c49
@katraev katraev authored alekseyrybalkin committed
Showing with 15 additions and 0 deletions.
  1. +15 −0 frontik/handler.py
View
15 frontik/handler.py
@@ -26,6 +26,21 @@
import frontik.handler_debug
import frontik.future as future
+from tornado.httpserver import HTTPRequest
+
+
+#patching for logging post reqs without body for security
+def context_based_repr(self):
+ attrs = ["protocol", "host", "method", "uri", "version", "remote_ip"]
+ if self.request.method != "POST" or tornado.options.options.debug:
+ attrs.append("body")
+ args = ", ".join(["%s=%r" % (n, getattr(self, n)) for n in attrs])
+ return "%s(%s, headers=%s)" % (
+ self.__class__.__name__, args, dict(self.headers))
+
+
+HTTPRequest.__repr__ = context_based_repr
+
def _parse_response_smth(response, logger = frontik_logging.log, parser=None, type=None):
_preview_len = 100
try:
Please sign in to comment.
Something went wrong with that request. Please try again.