From dc3b3c4209759abd658e9e27cb52d13e6f65f4b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 26 Apr 2008 11:08:08 +0000 Subject: [PATCH] flush only once if there's no payload git-svn-id: http://trooper/svn/projects/jFCPlib/branch/high-level-client@840 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/fcp/FcpMessage.java | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/net/pterodactylus/fcp/FcpMessage.java b/src/net/pterodactylus/fcp/FcpMessage.java index cac9196..ff65a98 100644 --- a/src/net/pterodactylus/fcp/FcpMessage.java +++ b/src/net/pterodactylus/fcp/FcpMessage.java @@ -32,7 +32,7 @@ import java.util.Map.Entry; * An FCP message. FCP messages consist of a name, an arbitrary amount of * “fields” (i.e. key-value pairs), a message end marker, and optional payload * data that follows the marker. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> * @version $Id$ */ @@ -52,7 +52,7 @@ public class FcpMessage implements Iterable { /** * Creates a new FCP message with the given name. - * + * * @param name * The name of the FCP message */ @@ -64,7 +64,7 @@ public class FcpMessage implements Iterable { * Creates a new FCP message with the given name and the given payload input * stream. The payload input stream is not read until the message is sent to * the node using {@link FcpConnection#sendMessage(FcpMessage)}. - * + * * @param name * The name of the message * @param payloadInputStream @@ -77,7 +77,7 @@ public class FcpMessage implements Iterable { /** * Returns the name of the message. - * + * * @return The name of the message */ public String getName() { @@ -86,7 +86,7 @@ public class FcpMessage implements Iterable { /** * Checks whether this message has a field with the given name. - * + * * @param field * The name of the field to check for * @return true if the message has a field with the given @@ -99,7 +99,7 @@ public class FcpMessage implements Iterable { /** * Sets the field with the given name to the given value. If the field * already exists in this message it is overwritten. - * + * * @param field * The name of the field * @param value @@ -114,7 +114,7 @@ public class FcpMessage implements Iterable { /** * Returns the value of the given field. - * + * * @param field * The name of the field * @return The value of the field, or null if there is no @@ -126,7 +126,7 @@ public class FcpMessage implements Iterable { /** * Returns all fields of this message. - * + * * @return All fields of this message */ public Map getFields() { @@ -142,7 +142,7 @@ public class FcpMessage implements Iterable { /** * Sets the payload input stream of the message. - * + * * @param payloadInputStream * The payload input stream */ @@ -156,7 +156,7 @@ public class FcpMessage implements Iterable { * the payload is written to the given output stream after the message as * well. That means that this method can only be called once because on the * second invocation the payload input stream could not be read (again). - * + * * @param outputStream * The output stream to write the message to * @throws IOException @@ -171,8 +171,8 @@ public class FcpMessage implements Iterable { outputStream.flush(); if (payloadInputStream != null) { FcpUtils.copy(payloadInputStream, outputStream); + outputStream.flush(); } - outputStream.flush(); } // @@ -182,7 +182,7 @@ public class FcpMessage implements Iterable { /** * Writes the given line (followed by {@link #LINEFEED} to the given output * stream, using UTF-8 as encoding. - * + * * @param outputStream * The output stream to write to * @param line -- 2.7.4