Commit e4ed261b authored by Dave Cridland's avatar Dave Cridland

Merge pull request #209 from tevans/OF-909

OF-909: Include ack in BOSH response body element
parents 606d34c2 8e19f5ba
......@@ -299,9 +299,9 @@ public class HttpBindServlet extends HttpServlet {
if (async) {
response.getOutputStream().setWriteListener(new WriteListenerImpl(context, byteContent));
} else {
// BOSH communication should not have Chunked encoding. Ensure that the
// buffer can hold the entire response to prevent chunking.
context.getResponse().setBufferSize(byteContent.length);
// BOSH communication should not use Chunked encoding.
// This is prevented by explicitly setting the Content-Length header.
context.getResponse().setContentLength(byteContent.length);
context.getResponse().getOutputStream().write(byteContent);
context.getResponse().getOutputStream().flush();
context.complete();
......@@ -348,14 +348,6 @@ public class HttpBindServlet extends HttpServlet {
sendLegacyError(context, error, null);
}
protected static String createEmptyBody(boolean terminate)
{
final Element body = DocumentHelper.createElement("body");
if (terminate) { body.addAttribute("type", "terminate"); }
body.addNamespace("", "http://jabber.org/protocol/httpbind");
return body.asXML();
}
protected static String createErrorBody(String type, String condition) {
final Element body = DocumentHelper.createElement("body");
body.addNamespace("", "http://jabber.org/protocol/httpbind");
......
......@@ -122,9 +122,9 @@ public class HttpConnection {
}
if (body == null) {
body = HttpBindServlet.createEmptyBody(false);
body = getSession().createEmptyBody(false);
}
HttpBindServlet.respond(this.getSession(), this.context, body, async);
HttpBindServlet.respond(getSession(), this.context, body, async);
}
/**
......
......@@ -710,7 +710,7 @@ public class HttpSession extends LocalClientSession {
try {
// If onTimeout does not result in a complete(), the container falls back to default behavior.
// This is why this body is to be delivered in a non-async fashion.
connection.deliverBody(createEmptyBody(), false);
connection.deliverBody(createEmptyBody(false), false);
setLastResponseEmpty(true);
// This connection timed out we need to increment the request count
......@@ -1014,13 +1014,8 @@ public class HttpSession extends LocalClientSession {
private String createDeliverable(Collection<Deliverable> elements) {
StringBuilder builder = new StringBuilder();
builder.append("<body xmlns='" + "http://jabber.org/protocol/httpbind" + "'");
long ack = getLastAcknowledged();
if(ack > lastRequestID)
builder.append(" ack='").append(ack).append("'");
builder.append(">");
builder.append("<body xmlns='http://jabber.org/protocol/httpbind' ack='")
.append(getLastAcknowledged()).append("'>");
setLastResponseEmpty(elements.size() == 0);
synchronized (elements) {
......@@ -1095,20 +1090,12 @@ public class HttpSession extends LocalClientSession {
});
}
private String createEmptyBody() {
Element body = DocumentHelper.createElement("body");
body.addNamespace("", "http://jabber.org/protocol/httpbind");
long ack = getLastAcknowledged();
if(ack > lastRequestID)
body.addAttribute("ack", String.valueOf(ack));
return body.asXML();
}
protected static String createEmptyBody(boolean terminate)
protected String createEmptyBody(boolean terminate)
{
final Element body = DocumentHelper.createElement("body");
if (terminate) { body.addAttribute("type", "terminate"); }
body.addNamespace("", "http://jabber.org/protocol/httpbind");
body.addAttribute("ack", String.valueOf(getLastAcknowledged()));
return body.asXML();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment