[Twisted-Python] [PATCH] Recognise multiple possible line-endings for LineReciever

The attached patch changes LineReceiver to call out to self.splitAtNewline for line splitting rather than doing it within dataReceived. It doesn't change the default behaviour in any way. However, if the user chooses to change their protocol from: | class MyProto(base.LineReceiver): | ... to | class MyProto(base.MultiLinebreakMixin, base.LineReceiver) | ... lines will be split on the first (or longest, if there's a tie) line-break in the list self.newlines (by default, CRLF, CR, LF). This has the effect that I can netcat (nc) to servers and they'll treat my \n as a newline. I dropped a unit test into test_protocol.py and it even passes! I'm afraid the patch is relative to 0.17-3; I can't cope with new versions every day ;) Oh yeah: I hereby relinquish copyright for the code in the attached patch and any subsequent code I contribute to Twisted, to Matthew Lefkowitz. Much good may it do him :> -- PORTLAND PLYMOUTH MAINLY WESTERLY 5 OR 6. SHOWERS. GOOD
participants (1)
-
Andrew Stribblehill