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);
|
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 {
|
try {
|
||||||
int messageNumber = Integer.valueOf(tokens.nextToken()) - 1;
|
int messageNumber = Integer.valueOf(tokens.nextToken()) - 1;
|
||||||
sendOK("");
|
sendOK("");
|
||||||
IOUtil.write(messages.get(messageNumber).getRawInputStream(), new DoubleDotOutputStream(os));
|
DoubleDotOutputStream doubleDotOutputStream = new DoubleDotOutputStream(os);
|
||||||
sendClient("");
|
IOUtil.write(messages.get(messageNumber).getRawInputStream(), doubleDotOutputStream);
|
||||||
sendClient(".");
|
doubleDotOutputStream.close();
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
// can not send error to client after a socket exception
|
// can not send error to client after a socket exception
|
||||||
DavGatewayTray.warn(new BundleMessage("LOG_CLIENT_CLOSED_CONNECTION"), e);
|
DavGatewayTray.warn(new BundleMessage("LOG_CLIENT_CLOSED_CONNECTION"), e);
|
||||||
@ -234,9 +234,9 @@ public class PopConnection extends AbstractConnection {
|
|||||||
int lines = Integer.valueOf(tokens.nextToken());
|
int lines = Integer.valueOf(tokens.nextToken());
|
||||||
ExchangeSession.Message m = messages.get(message - 1);
|
ExchangeSession.Message m = messages.get(message - 1);
|
||||||
sendOK("");
|
sendOK("");
|
||||||
IOUtil.write(m.getRawInputStream(), new TopOutputStream(new DoubleDotOutputStream(os), lines));
|
DoubleDotOutputStream doubleDotOutputStream = new DoubleDotOutputStream(os);
|
||||||
sendClient("");
|
IOUtil.write(m.getRawInputStream(), doubleDotOutputStream);
|
||||||
sendClient(".");
|
doubleDotOutputStream.close();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
sendERR("invalid command");
|
sendERR("invalid command");
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user