summaryrefslogtreecommitdiffstats
path: root/obex/javax/obex/ServerOperation.java
diff options
context:
space:
mode:
Diffstat (limited to 'obex/javax/obex/ServerOperation.java')
-rw-r--r--obex/javax/obex/ServerOperation.java43
1 files changed, 27 insertions, 16 deletions
diff --git a/obex/javax/obex/ServerOperation.java b/obex/javax/obex/ServerOperation.java
index d1476d271cf..b2dd33f45bd 100644
--- a/obex/javax/obex/ServerOperation.java
+++ b/obex/javax/obex/ServerOperation.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Copyright (c) 2008-2009, Motorola, Inc.
*
* All rights reserved.
@@ -88,6 +89,7 @@ public final class ServerOperation implements Operation, BaseStream {
private boolean mHasBody;
+ private boolean mEndofBody = true;
/**
* Creates new ServerOperation
* @param p the parent that created this object
@@ -364,28 +366,33 @@ public final class ServerOperation implements Operation, BaseStream {
* (End of Body) otherwise, we need to send 0x48 (Body)
*/
if ((finalBitSet) || (mPrivateOutput.isClosed())) {
- out.write(0x49);
+ if (mEndofBody) {
+ out.write(0x49);
+ bodyLength += 3;
+ out.write((byte)(bodyLength >> 8));
+ out.write((byte)bodyLength);
+ out.write(body);
+ }
} else {
out.write(0x48);
+ bodyLength += 3;
+ out.write((byte)(bodyLength >> 8));
+ out.write((byte)bodyLength);
+ out.write(body);
}
-
- bodyLength += 3;
- out.write((byte)(bodyLength >> 8));
- out.write((byte)bodyLength);
- out.write(body);
}
}
- if ((finalBitSet) && (type == ResponseCodes.OBEX_HTTP_OK) && (orginalBodyLength <= 0)) {
- out.write(0x49);
- orginalBodyLength = 3;
- out.write((byte)(orginalBodyLength >> 8));
- out.write((byte)orginalBodyLength);
-
- }
-
- mResponseSize = 3;
- mParent.sendResponse(type, out.toByteArray());
+ if ((finalBitSet) && (type == ResponseCodes.OBEX_HTTP_OK) && (orginalBodyLength <= 0)) {
+ if (mEndofBody) {
+ out.write(0x49);
+ orginalBodyLength = 3;
+ out.write((byte)(orginalBodyLength >> 8));
+ out.write((byte)orginalBodyLength);
+ }
+ }
+ mResponseSize = 3;
+ mParent.sendResponse(type, out.toByteArray());
if (type == ResponseCodes.OBEX_HTTP_CONTINUE) {
int headerID = mInput.read();
@@ -711,4 +718,8 @@ public final class ServerOperation implements Operation, BaseStream {
public void streamClosed(boolean inStream) throws IOException {
}
+
+ public void noEndofBody() {
+ mEndofBody = false;
+ }
}