@@ -46,11 +46,24 @@ def process_request(self, request):
46
46
for var , val in request .META .items ():
47
47
if var .startswith ('HTTP_' ):
48
48
var = var [5 :].replace ('_' , '-' ).title ()
49
- req += '%s: %s\n ' % (self .logger .style .SQL_FIELD (var ), val )
49
+ req += '%s: %s\n ' % (self .logger .style .SQL_KEYWORD (var ), val )
50
50
if request .META ['CONTENT_LENGTH' ]:
51
- req += '%s: %s\n ' % (self .logger .style .SQL_FIELD ('Content-Length' ), request .META ['CONTENT_LENGTH' ])
51
+ req += '%s: %s\n ' % (self .logger .style .SQL_KEYWORD ('Content-Length' ), request .META ['CONTENT_LENGTH' ])
52
52
if request .POST :
53
53
req += '\n %s\n ' % self .logger .style .HTTP_INFO (urllib .urlencode (dict ((k , v .encode ('utf8' )) for k , v in request .POST .items ())))
54
54
if request .FILES :
55
55
req += '\n %s\n ' % self .logger .style .HTTP_NOT_MODIFIED (urllib .urlencode (request .FILES ))
56
56
self .logger .info ('Full request:\n %s' , req )
57
+
58
+ class ResponseDumpModule (DevServerModule ):
59
+ """
60
+ Dumps the request headers and variables.
61
+ """
62
+
63
+ logger_name = 'response'
64
+
65
+ def process_response (self , request , response ):
66
+ res = self .logger .style .SQL_FIELD ('Status code: %s\n ' % response .status_code )
67
+ res += '\n ' .join (['%s: %s' % (self .logger .style .SQL_FIELD (k ), v )
68
+ for k , v in response ._headers .values ()])
69
+ self .logger .info ('Full response:\n %s' , res )
0 commit comments