OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 | 3 |
4 # Copyright 2014 The Crashpad Authors. All rights reserved. | 4 # Copyright 2014 The Crashpad Authors. All rights reserved. |
5 # | 5 # |
6 # Licensed under the Apache License, Version 2.0 (the "License"); | 6 # Licensed under the Apache License, Version 2.0 (the "License"); |
7 # you may not use this file except in compliance with the License. | 7 # you may not use this file except in compliance with the License. |
8 # You may obtain a copy of the License at | 8 # You may obtain a copy of the License at |
9 # | 9 # |
10 # http://www.apache.org/licenses/LICENSE-2.0 | 10 # http://www.apache.org/licenses/LICENSE-2.0 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 if chunk_size_end == -1: | 111 if chunk_size_end == -1: |
112 # No chunk extensions; just encounter the end of line. | 112 # No chunk extensions; just encounter the end of line. |
113 chunk_size_end = chunk_size_and_ext_line.find('\r') | 113 chunk_size_end = chunk_size_and_ext_line.find('\r') |
114 if chunk_size_end == -1: | 114 if chunk_size_end == -1: |
115 self.send_response(400) # Bad request. | 115 self.send_response(400) # Bad request. |
116 return -1 | 116 return -1 |
117 return int(chunk_size_and_ext_line[:chunk_size_end], base=16) | 117 return int(chunk_size_and_ext_line[:chunk_size_end], base=16) |
118 | 118 |
119 | 119 |
120 def Main(): | 120 def Main(): |
| 121 if sys.platform == 'win32': |
| 122 import os, msvcrt |
| 123 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
| 124 |
121 # Start the server. | 125 # Start the server. |
122 server = BaseHTTPServer.HTTPServer(('127.0.0.1', 0), RequestHandler) | 126 server = BaseHTTPServer.HTTPServer(('127.0.0.1', 0), RequestHandler) |
123 | 127 |
124 # Write the port as an unsigned short to the parent process. | 128 # Write the port as an unsigned short to the parent process. |
125 sys.stdout.write(struct.pack('=H', server.server_address[1])) | 129 sys.stdout.write(struct.pack('=H', server.server_address[1])) |
126 sys.stdout.flush() | 130 sys.stdout.flush() |
127 | 131 |
128 # Read the desired test response code as an unsigned short from the parent | 132 # Read the desired test response code as an unsigned short from the parent |
129 # process. | 133 # process. |
130 RequestHandler.response_code = \ | 134 RequestHandler.response_code = \ |
131 struct.unpack('=H', sys.stdin.read(struct.calcsize('=H')))[0] | 135 struct.unpack('=H', sys.stdin.read(struct.calcsize('=H')))[0] |
132 | 136 |
133 # Handle the request. | 137 # Handle the request. |
134 server.handle_request() | 138 server.handle_request() |
135 | 139 |
136 if __name__ == '__main__': | 140 if __name__ == '__main__': |
137 Main() | 141 Main() |
OLD | NEW |