Skip to content

Commit

Permalink
Merge "Bluetooth: Send GET request as single packet"
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket Agarwal authored and Gerrit Code Review committed Jun 21, 2016
2 parents cf81fdb + eed3200 commit 3d20e6f
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions obex/javax/obex/ClientOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -632,21 +632,32 @@ private synchronized void startProcessing() throws IOException {

if (mGetOperation) {
if (!mOperationDone) {
mReplyHeader.responseCode = ResponseCodes.OBEX_HTTP_CONTINUE;
while ((more) && (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE)) {
more = sendRequest(ObexHelper.OBEX_OPCODE_GET);
}
// For GET we need to loop until all headers have been sent,
// And then we wait for the first continue package with the
// reply.
if (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE) {
mParent.sendRequest(ObexHelper.OBEX_OPCODE_GET_FINAL,
null, mReplyHeader, mPrivateInput, mSrmActive);
}
if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) {
mOperationDone = true;
if (!mGetFinalFlag) {
mReplyHeader.responseCode = ResponseCodes.OBEX_HTTP_CONTINUE;
while ((more) && (mReplyHeader.responseCode ==
ResponseCodes.OBEX_HTTP_CONTINUE)) {
more = sendRequest(ObexHelper.OBEX_OPCODE_GET);
}
// For GET we need to loop until all headers have been sent,
// And then we wait for the first continue package with the
// reply.
if (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE) {
mParent.sendRequest(ObexHelper.OBEX_OPCODE_GET_FINAL,
null, mReplyHeader, mPrivateInput, mSrmActive);
}
if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) {
mOperationDone = true;
} else {
checkForSrm();
}
} 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 {
Expand Down Expand Up @@ -705,7 +716,15 @@ public synchronized boolean continueOperation(boolean sendEmpty, boolean inStrea
if (mPrivateInput == null) {
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;

} else if (mOperationDone) {
Expand Down

0 comments on commit 3d20e6f

Please sign in to comment.