Florent Xicluna added the comment:
IMHO this code will do the trick:
while not request_buffer.endswith(('\r', '\n')):
request_buffer += self.conn.recv(1024)
print("Got a line!")
print("Got an empty line!")
self.handleRequest(request_buffer)
--
nosy: +flox
David added the comment:
Thank you for the clarification, David. I thought that it might have been a
calculated decision beyond my understanding, and I can rest easy knowing that
this behavior isn't accidental. I was thinking that I might have to do
something like a regular expression, and I
R. David Murray added the comment:
No apologies needed, but you probably aren't going to like the answer :)
First of all, a change like you propose would be unlikely to be accepted since
it would create considerable backward-compatibility pain.
That aside, however, splitlines and split are no
David added the comment:
I typoed when copying my second snippet.
while request_buffer.splitlines[-1] != "" or request_buffer == "":
It should be:
while request_buffer.splitlines()[-1] != "" or request_buffer == "":
This code has the problem that I'm complaining of. I only failed at copyin
New submission from David :
Qualifier: This is the first issue that I've raised, so I apologise before-hand
for any protocol flubs.
str.splitlines()'s implementation jives unexpectedly with str.split().
In this code snippet, a server buffers input until it receives a blank line,
and then it p