Commit c5222a21 authored by David Smith's avatar David Smith Committed by david

Add additional logging to help track down XIFF-31; r=Gato

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10599 b35dd754-fafc-0310-a699-88a17e54d16e
parent 10b22fbe
...@@ -137,9 +137,6 @@ public class HttpBindServlet extends HttpServlet { ...@@ -137,9 +137,6 @@ public class HttpBindServlet extends HttpServlet {
return; return;
} }
if (JiveGlobals.getBooleanProperty("log.httpbind.enabled", false)) {
System.out.println(new Date()+": HTTP RECV: " + document.asXML());
}
Element node = document.getRootElement(); Element node = document.getRootElement();
if (node == null || !"body".equals(node.getName())) { if (node == null || !"body".equals(node.getName())) {
Log.warn("Body missing from request content. [" + request.getRemoteAddr() + "]"); Log.warn("Body missing from request content. [" + request.getRemoteAddr() + "]");
...@@ -148,6 +145,7 @@ public class HttpBindServlet extends HttpServlet { ...@@ -148,6 +145,7 @@ public class HttpBindServlet extends HttpServlet {
} }
String sid = node.attributeValue("sid"); String sid = node.attributeValue("sid");
// We have a new session // We have a new session
if (sid == null) { if (sid == null) {
createNewSession(request, response, node); createNewSession(request, response, node);
...@@ -166,7 +164,7 @@ public class HttpBindServlet extends HttpServlet { ...@@ -166,7 +164,7 @@ public class HttpBindServlet extends HttpServlet {
} }
synchronized (session) { synchronized (session) {
try { try {
respond(response, session.getResponse((Long) request.getAttribute("request")), respond(session, response, session.getResponse((Long) request.getAttribute("request")),
request.getMethod()); request.getMethod());
} }
catch (HttpBindException e) { catch (HttpBindException e) {
...@@ -180,9 +178,12 @@ public class HttpBindServlet extends HttpServlet { ...@@ -180,9 +178,12 @@ public class HttpBindServlet extends HttpServlet {
BoshBindingError bindingError, HttpSession session) BoshBindingError bindingError, HttpSession session)
throws IOException throws IOException
{ {
if (JiveGlobals.getBooleanProperty("log.httpbind.enabled", false)) {
System.out.println(new Date()+": HTTP ERR("+session.getStreamID().getID() + "): " + bindingError.getErrorType().getType() + ", " + bindingError.getCondition() + ".");
}
try { try {
if (session.getVersion() >= 1.6) { if (session.getVersion() >= 1.6) {
respond(response, createErrorBody(bindingError.getErrorType().getType(), respond(session, response, createErrorBody(bindingError.getErrorType().getType(),
bindingError.getCondition()), request.getMethod()); bindingError.getCondition()), request.getMethod());
} }
else { else {
...@@ -208,6 +209,9 @@ public class HttpBindServlet extends HttpServlet { ...@@ -208,6 +209,9 @@ public class HttpBindServlet extends HttpServlet {
HttpServletResponse response, Element rootNode) HttpServletResponse response, Element rootNode)
throws IOException throws IOException
{ {
if (JiveGlobals.getBooleanProperty("log.httpbind.enabled", false)) {
System.out.println(new Date()+": HTTP RECV(" + sid + "): " + rootNode.asXML());
}
long rid = getLongAttribue(rootNode.attributeValue("rid"), -1); long rid = getLongAttribue(rootNode.attributeValue("rid"), -1);
if (rid <= 0) { if (rid <= 0) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Body missing RID (Request ID)"); response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Body missing RID (Request ID)");
...@@ -239,14 +243,14 @@ public class HttpBindServlet extends HttpServlet { ...@@ -239,14 +243,14 @@ public class HttpBindServlet extends HttpServlet {
String type = rootNode.attributeValue("type"); String type = rootNode.attributeValue("type");
if ("terminate".equals(type)) { if ("terminate".equals(type)) {
session.close(); session.close();
respond(response, createEmptyBody(), request.getMethod()); respond(session, response, createEmptyBody(), request.getMethod());
} }
else { else {
connection.setContinuation(ContinuationSupport.getContinuation(request, connection)); connection.setContinuation(ContinuationSupport.getContinuation(request, connection));
request.setAttribute("request-session", connection.getSession()); request.setAttribute("request-session", connection.getSession());
request.setAttribute("request", connection.getRequestId()); request.setAttribute("request", connection.getRequestId());
try { try {
respond(response, session.getResponse(connection.getRequestId()), respond(session, response, session.getResponse(connection.getRequestId()),
request.getMethod()); request.getMethod());
} }
catch (HttpBindException e) { catch (HttpBindException e) {
...@@ -272,6 +276,9 @@ public class HttpBindServlet extends HttpServlet { ...@@ -272,6 +276,9 @@ public class HttpBindServlet extends HttpServlet {
HttpConnection connection = new HttpConnection(rid, request.isSecure(), certificates); HttpConnection connection = new HttpConnection(rid, request.isSecure(), certificates);
InetAddress address = InetAddress.getByName(request.getRemoteAddr()); InetAddress address = InetAddress.getByName(request.getRemoteAddr());
connection.setSession(sessionManager.createSession(address, rootNode, connection)); connection.setSession(sessionManager.createSession(address, rootNode, connection));
if (JiveGlobals.getBooleanProperty("log.httpbind.enabled", false)) {
System.out.println(new Date()+": HTTP RECV(" + connection.getSession().getStreamID().getID() + "): " + rootNode.asXML());
}
respond(response, connection, request.getMethod()); respond(response, connection, request.getMethod());
} }
catch (UnauthorizedException e) { catch (UnauthorizedException e) {
...@@ -296,10 +303,10 @@ public class HttpBindServlet extends HttpServlet { ...@@ -296,10 +303,10 @@ public class HttpBindServlet extends HttpServlet {
content = createEmptyBody(); content = createEmptyBody();
} }
respond(response, content, method); respond(connection.getSession(), response, content, method);
} }
private void respond(HttpServletResponse response, String content, String method) private void respond(HttpSession session, HttpServletResponse response, String content, String method)
throws IOException { throws IOException {
response.setStatus(HttpServletResponse.SC_OK); response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("GET".equals(method) ? "text/javascript" : "text/xml"); response.setContentType("GET".equals(method) ? "text/javascript" : "text/xml");
...@@ -310,7 +317,7 @@ public class HttpBindServlet extends HttpServlet { ...@@ -310,7 +317,7 @@ public class HttpBindServlet extends HttpServlet {
} }
if (JiveGlobals.getBooleanProperty("log.httpbind.enabled", false)) { if (JiveGlobals.getBooleanProperty("log.httpbind.enabled", false)) {
System.out.println(new Date()+": HTTP SENT: " + content); System.out.println(new Date()+": HTTP SENT(" + session.getStreamID().getID() + "): " + content);
} }
byte[] byteContent = content.getBytes("utf-8"); byte[] byteContent = content.getBytes("utf-8");
response.setContentLength(byteContent.length); response.setContentLength(byteContent.length);
......
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