Mercurial > hg
comparison tests/dummysmtpd.py @ 51710:8fe7c0e1df1e
dummysmtpd: fix EOF handling on newer versions of OpenSSL
Explanations inline.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 22 Jul 2024 14:42:54 +0200 |
parents | 7f0cb9ee0534 |
children | dbd2d56224d1 |
comparison
equal
deleted
inserted
replaced
51709:57f0b86611c7 | 51710:8fe7c0e1df1e |
---|---|
29 | 29 |
30 | 30 |
31 def mocksmtpserversession(conn, addr): | 31 def mocksmtpserversession(conn, addr): |
32 conn.send(b'220 smtp.example.com ESMTP\r\n') | 32 conn.send(b'220 smtp.example.com ESMTP\r\n') |
33 | 33 |
34 line = conn.recv(1024) | 34 try: |
35 # Newer versions of OpenSSL raise on EOF | |
36 line = conn.recv(1024) | |
37 except ssl.SSLError: | |
38 log('no hello: EOF\n') | |
39 return | |
40 | |
35 if not line.lower().startswith(b'ehlo '): | 41 if not line.lower().startswith(b'ehlo '): |
42 # Older versions of OpenSSl don't raise | |
36 log('no hello: %s\n' % line) | 43 log('no hello: %s\n' % line) |
37 return | 44 return |
38 | 45 |
39 conn.send(b'250 Hello\r\n') | 46 conn.send(b'250 Hello\r\n') |
40 | 47 |