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

Delta Between Two Patch Sets: modules/adblockplus/files/mimeo.py

Issue 29525555: #622 - Use mimeo module on abb website (Closed)
Left Patch Set: For comment 2 Created Aug. 24, 2017, 6:18 p.m.
Right Patch Set: For comment 10 Created Aug. 24, 2017, 8:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « hiera/roles/web/adblockbrowser.yaml ('k') | modules/adblockplus/manifests/web/mimeo.pp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 22 matching lines...) Expand all
33 33
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 body_len = int(self.headers.get('content-length', 0)) 43 request_body_len = int(self.headers.get('content-length', 0))
44 body = self.rfile.read(body_len).decode('UTF-8') 44 request_body = self.rfile.read(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 'body': body, 51 'request_body': request_body,
mathias 2017/08/24 18:23:38 Wasn't that $request_body in Nginx?
52 } 52 }
53 values.update(self.get_header_values()) 53 values.update(self.get_header_values())
54 try: 54 try:
55 self.write_info(values) 55 self.write_info(values)
56 self.send_simple_response(status, content) 56 self.send_simple_response(status, content)
57 except: 57 except:
58 traceback.print_exc(file=sys.stderr) 58 traceback.print_exc(file=sys.stderr)
59 self.send_simple_response(500) 59 self.send_simple_response(500)
60 60
61 61
(...skipping 20 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()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld