Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/adblockplus/files/mimeo.py

Issue 29586670: Use correct variable name for request body length (Closed)
Patch Set: Created Oct. 23, 2017, 3:43 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 2
3 import argparse 3 import argparse
4 import re 4 import re
5 import sys 5 import sys
6 import threading 6 import threading
7 import traceback 7 import traceback
8 8
9 from http.server import BaseHTTPRequestHandler, HTTPServer 9 from http.server import BaseHTTPRequestHandler, HTTPServer
10 from string import Template 10 from string import Template
(...skipping 23 matching lines...) Expand all
34 def write_info(self, args): 34 def write_info(self, args):
35 message = Template(self.format).safe_substitute(args) + '\n' 35 message = Template(self.format).safe_substitute(args) + '\n'
36 with _lock: 36 with _lock:
37 self.output.write(message) 37 self.output.write(message)
38 self.output.flush() 38 self.output.flush()
39 39
40 def do_POST(self): 40 def do_POST(self):
41 status = 200 41 status = 200
42 content = bytes(self.response, 'UTF-8') 42 content = bytes(self.response, 'UTF-8')
43 request_body_len = int(self.headers.get('content-length', 0)) 43 request_body_len = int(self.headers.get('content-length', 0))
44 request_body = self.rfile.read(body_len).decode('UTF-8') 44 request_body = self.rfile.read(request_body_len).decode('UTF-8')
45 values = { 45 values = {
46 'remote_addr': self.address_string(), 46 'remote_addr': self.address_string(),
47 'time_local': self.log_date_time_string(), 47 'time_local': self.log_date_time_string(),
48 'request': self.requestline, 48 'request': self.requestline,
49 'status': status, 49 'status': status,
50 'bytes_sent': len(content), 50 'bytes_sent': len(content),
51 'request_body': request_body, 51 'request_body': request_body,
52 } 52 }
53 values.update(self.get_header_values()) 53 values.update(self.get_header_values())
54 try: 54 try:
(...skipping 27 matching lines...) Expand all
82 fh = open(sys.stdout.fileno(), 'w', closefd=False) 82 fh = open(sys.stdout.fileno(), 'w', closefd=False)
83 try: 83 try:
84 Handler.output = fh 84 Handler.output = fh
85 Handler.format = args.format 85 Handler.format = args.format
86 Handler.response = args.response 86 Handler.response = args.response
87 server_address = ('', args.port) 87 server_address = ('', args.port)
88 httpd = HTTPServer(server_address, Handler) 88 httpd = HTTPServer(server_address, Handler)
89 httpd.serve_forever() 89 httpd.serve_forever()
90 finally: 90 finally:
91 fh.close() 91 fh.close()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld