Skip to content

Commit

Permalink
pep8 corrections made
Browse files Browse the repository at this point in the history
Codeclimate marks (wrongly) similarities in two completely different methods.
  • Loading branch information
FosanzDev committed Jun 24, 2024
1 parent 346686e commit 5bceca1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
6 changes: 3 additions & 3 deletions tlslite/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
try:
from .integration.tlsasyncdispatchermixin import TLSAsyncDispatcherMixIn
except ImportError:
# NOTE: Left this try-except block as is, due to the possibility to use both
# asyncore and asyncio in the same project no matter the python version (if the
# asyncore module is available).
# NOTE: Left this try-except block as is, due to the possibility to use
# both asyncore and asyncio in the same project no matter the python
# version (if the asyncore module is available).
pass

from .integration.pop3_tls import POP3_TLS
Expand Down
2 changes: 1 addition & 1 deletion tlslite/integration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"xmlrpctransport",
"tlssocketservermixin",
"tlsasyncdispatchermixin",
"tlsasynciodispatchermixin"]
"tlsasynciodispatchermixin"]
49 changes: 30 additions & 19 deletions tlslite/integration/tlsasynciodispatchermixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,42 @@

class TLSAsyncioDispatcherMixIn(asyncio.Protocol):
"""
This class can be "mixed in" with an :py:class:`asyncio.Protocol` to add TLS support.
This class can be "mixed in" with an :py:class:`asyncio.Protocol`
to add TLS support.
This class essentially sits between the protocol and the asyncio event loop, intercepting events and only
This class essentially sits between the protocol and the asyncio
event loop, intercepting events and only
calling the protocol when applicable.
In the case of :py:meth:`data_received`, a read operation will be activated, and when it completes,
the bytes will be placed in a buffer where the protocol can retrieve them by calling :py:meth:`recv`,
In the case of :py:meth:`data_received`, a read operation will be
activated, and when it completes, the bytes will be placed in a
buffer where the protocol can retrieve them by calling :py:meth:`recv`,
and the protocol's :py:meth:`data_received` will be called.
In the case of :py:meth:`send`, the protocol's :py:meth:`send` will be called, and when it calls
:py:meth:`send`, a write operation will be activated.
In the case of :py:meth:`send`, the protocol's :py:meth:`send` will
be called, and when it calls :py:meth:`send`, a write operation
will be activated.
To use this class, you must combine it with an asyncio.Protocol, and pass in a handshake operation with
setServerHandshakeOp().
To use this class, you must combine it with an asyncio.Protocol, and
pass in a handshake operation with setServerHandshakeOp().
Below is an example of using this class with aiohttp. This class is mixed in with aiohttp's BaseProtocol to
create http_tls_protocol. Note:
Below is an example of using this class with aiohttp. This class
is mixed in with aiohttp's BaseProtocol to create http_tls_protocol.
Note:
1. the mix-in is listed first in the inheritance list
2. the input buffer size must be at least 16K, otherwise the protocol might not read all the bytes from the
TLS layer, leaving some bytes in limbo.
2. the input buffer size must be at least 16K, otherwise the protocol
might not read all the bytes from the TLS layer, leaving some
bytes in limbo.
3. IE seems to have a problem receiving a whole HTTP response in a single TLS record, so HTML pages
containing '\\r\\n\\r\\n' won't be displayed on IE.
3. IE seems to have a problem receiving a whole HTTP response
in a single TLS record, so HTML pages containing
'\\r\\n\\r\\n' won't be displayed on IE.
Add the following text into 'start_aiohttp.py', in the 'HTTP Server' section::
Add the following text into 'start_aiohttp.py', in the
'HTTP Server' section::
from tlslite import *
s = open("./serverX509Cert.pem").read()
Expand All @@ -62,10 +71,12 @@ def __init__ (self, server, conn, addr):
hs.protocol_class = http_tls_protocol
If the TLS layer raises an exception, the exception will be caught in asyncio.Protocol, which will call
:py:meth:`close` on this class. The TLS layer always closes the TLS connection before raising an exception,
so the close operation will complete right away, causing asyncio.Protocol.close() to be called, which closes
the socket and removes this instance from the asyncio event loop.
If the TLS layer raises an exception, the exception will be caught in
asyncio.Protocol, which will call :py:meth:`close` on this class.
The TLS layer always closes the TLS connection before raising an
exception, so the close operation will complete right away, causing
asyncio.Protocol.close() to be called, which closes the socket and
removes this instance from the asyncio event loop.
"""

def __init__(self, sock=None):
Expand Down

0 comments on commit 5bceca1

Please sign in to comment.