Merge "Bluetooth: Send GET request as single packet"

This commit is contained in:
Sanket Agarwal
2016-06-21 20:37:36 +00:00
committed by Gerrit Code Review

View File

@@ -632,21 +632,32 @@ public final class ClientOperation implements Operation, BaseStream {
if (mGetOperation) { if (mGetOperation) {
if (!mOperationDone) { if (!mOperationDone) {
mReplyHeader.responseCode = ResponseCodes.OBEX_HTTP_CONTINUE; if (!mGetFinalFlag) {
while ((more) && (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE)) { mReplyHeader.responseCode = ResponseCodes.OBEX_HTTP_CONTINUE;
more = sendRequest(ObexHelper.OBEX_OPCODE_GET); while ((more) && (mReplyHeader.responseCode ==
} ResponseCodes.OBEX_HTTP_CONTINUE)) {
// For GET we need to loop until all headers have been sent, more = sendRequest(ObexHelper.OBEX_OPCODE_GET);
// And then we wait for the first continue package with the }
// reply. // For GET we need to loop until all headers have been sent,
if (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE) { // And then we wait for the first continue package with the
mParent.sendRequest(ObexHelper.OBEX_OPCODE_GET_FINAL, // reply.
null, mReplyHeader, mPrivateInput, mSrmActive); if (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE) {
} mParent.sendRequest(ObexHelper.OBEX_OPCODE_GET_FINAL,
if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) { null, mReplyHeader, mPrivateInput, mSrmActive);
mOperationDone = true; }
if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) {
mOperationDone = true;
} else {
checkForSrm();
}
} else { } else {
checkForSrm(); more = sendRequest(ObexHelper.OBEX_OPCODE_GET_FINAL);
if (more) {
throw new IOException("FINAL_GET forced, data didn't fit into one packet");
}
mOperationDone = true;
} }
} }
} else { } else {
@@ -705,7 +716,15 @@ public final class ClientOperation implements Operation, BaseStream {
if (mPrivateInput == null) { if (mPrivateInput == null) {
mPrivateInput = new PrivateInputStream(this); mPrivateInput = new PrivateInputStream(this);
} }
sendRequest(ObexHelper.OBEX_OPCODE_GET);
if (!mGetFinalFlag) {
sendRequest(ObexHelper.OBEX_OPCODE_GET);
} else {
sendRequest(ObexHelper.OBEX_OPCODE_GET_FINAL);
}
if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) {
mOperationDone = true;
}
return true; return true;
} else if (mOperationDone) { } else if (mOperationDone) {