Show More
@@ -197,47 +197,6 b' class _httprequesthandler(BaseHTTPServer' | |||||
197 | self.wfile.write('0\r\n\r\n') |
|
197 | self.wfile.write('0\r\n\r\n') | |
198 | self.wfile.flush() |
|
198 | self.wfile.flush() | |
199 |
|
199 | |||
200 | class _httprequesthandleropenssl(_httprequesthandler): |
|
|||
201 | """HTTPS handler based on pyOpenSSL""" |
|
|||
202 |
|
||||
203 | url_scheme = 'https' |
|
|||
204 |
|
||||
205 | @staticmethod |
|
|||
206 | def preparehttpserver(httpserver, ssl_cert): |
|
|||
207 | try: |
|
|||
208 | import OpenSSL |
|
|||
209 | OpenSSL.SSL.Context |
|
|||
210 | except ImportError: |
|
|||
211 | raise error.Abort(_("SSL support is unavailable")) |
|
|||
212 | ctx = OpenSSL.SSL.Context(OpenSSL.SSL.TLSv1_METHOD) |
|
|||
213 | ctx.use_privatekey_file(ssl_cert) |
|
|||
214 | ctx.use_certificate_file(ssl_cert) |
|
|||
215 | sock = socket.socket(httpserver.address_family, httpserver.socket_type) |
|
|||
216 | httpserver.socket = OpenSSL.SSL.Connection(ctx, sock) |
|
|||
217 | httpserver.server_bind() |
|
|||
218 | httpserver.server_activate() |
|
|||
219 |
|
||||
220 | def setup(self): |
|
|||
221 | self.connection = self.request |
|
|||
222 | self.rfile = socket._fileobject(self.request, "rb", self.rbufsize) |
|
|||
223 | self.wfile = socket._fileobject(self.request, "wb", self.wbufsize) |
|
|||
224 |
|
||||
225 | def do_write(self): |
|
|||
226 | import OpenSSL |
|
|||
227 | try: |
|
|||
228 | _httprequesthandler.do_write(self) |
|
|||
229 | except OpenSSL.SSL.SysCallError as inst: |
|
|||
230 | if inst.args[0] != errno.EPIPE: |
|
|||
231 | raise |
|
|||
232 |
|
||||
233 | def handle_one_request(self): |
|
|||
234 | import OpenSSL |
|
|||
235 | try: |
|
|||
236 | _httprequesthandler.handle_one_request(self) |
|
|||
237 | except (OpenSSL.SSL.SysCallError, OpenSSL.SSL.ZeroReturnError): |
|
|||
238 | self.close_connection = True |
|
|||
239 | pass |
|
|||
240 |
|
||||
241 | class _httprequesthandlerssl(_httprequesthandler): |
|
200 | class _httprequesthandlerssl(_httprequesthandler): | |
242 | """HTTPS handler based on Python's ssl module""" |
|
201 | """HTTPS handler based on Python's ssl module""" | |
243 |
|
202 | |||
@@ -311,10 +270,7 b' class IPv6HTTPServer(MercurialHTTPServer' | |||||
311 | def create_server(ui, app): |
|
270 | def create_server(ui, app): | |
312 |
|
271 | |||
313 | if ui.config('web', 'certificate'): |
|
272 | if ui.config('web', 'certificate'): | |
314 | if sys.version_info >= (2, 6): |
|
273 | handler = _httprequesthandlerssl | |
315 | handler = _httprequesthandlerssl |
|
|||
316 | else: |
|
|||
317 | handler = _httprequesthandleropenssl |
|
|||
318 | else: |
|
274 | else: | |
319 | handler = _httprequesthandler |
|
275 | handler = _httprequesthandler | |
320 |
|
276 |
General Comments 0
You need to be logged in to leave comments.
Login now