mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 03:32:22 -05:00
POP: fix message termination, append CRLF only when necessary
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1206 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
ca090b7cbb
commit
d1278edad4
@ -56,4 +56,21 @@ public class DoubleDotOutputStream extends FilterOutputStream {
|
||||
out.write(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send termination characters.
|
||||
* Do not close actual outputstream
|
||||
*
|
||||
* @throws IOException on error
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (currentState != State.CRLF) {
|
||||
out.write('\r');
|
||||
out.write('\n');
|
||||
}
|
||||
out.write('.');
|
||||
out.write('\r');
|
||||
out.write('\n');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -197,9 +197,9 @@ public class PopConnection extends AbstractConnection {
|
||||
try {
|
||||
int messageNumber = Integer.valueOf(tokens.nextToken()) - 1;
|
||||
sendOK("");
|
||||
IOUtil.write(messages.get(messageNumber).getRawInputStream(), new DoubleDotOutputStream(os));
|
||||
sendClient("");
|
||||
sendClient(".");
|
||||
DoubleDotOutputStream doubleDotOutputStream = new DoubleDotOutputStream(os);
|
||||
IOUtil.write(messages.get(messageNumber).getRawInputStream(), doubleDotOutputStream);
|
||||
doubleDotOutputStream.close();
|
||||
} catch (SocketException e) {
|
||||
// can not send error to client after a socket exception
|
||||
DavGatewayTray.warn(new BundleMessage("LOG_CLIENT_CLOSED_CONNECTION"), e);
|
||||
@ -234,9 +234,9 @@ public class PopConnection extends AbstractConnection {
|
||||
int lines = Integer.valueOf(tokens.nextToken());
|
||||
ExchangeSession.Message m = messages.get(message - 1);
|
||||
sendOK("");
|
||||
IOUtil.write(m.getRawInputStream(), new TopOutputStream(new DoubleDotOutputStream(os), lines));
|
||||
sendClient("");
|
||||
sendClient(".");
|
||||
DoubleDotOutputStream doubleDotOutputStream = new DoubleDotOutputStream(os);
|
||||
IOUtil.write(m.getRawInputStream(), doubleDotOutputStream);
|
||||
doubleDotOutputStream.close();
|
||||
} catch (NumberFormatException e) {
|
||||
sendERR("invalid command");
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user