]> source.dussan.org Git - vaadin-framework.git/commitdiff
Don't try to redirect browser on failed heartbeat requests
authorJohannes Dahlström <johannesd@vaadin.com>
Wed, 12 Sep 2012 08:16:40 +0000 (11:16 +0300)
committerJohannes Dahlström <johannesd@vaadin.com>
Wed, 12 Sep 2012 08:17:19 +0000 (11:17 +0300)
server/src/com/vaadin/server/VaadinServlet.java

index c4173e1271f322ee33a3077d85e9ad827a74dcc9..9372a08e10ac1640562d6cb9e258f37604190183 100644 (file)
@@ -825,11 +825,8 @@ public class VaadinServlet extends HttpServlet implements Constants {
 
         try {
             SystemMessages ci = getVaadinService().getSystemMessages();
-            if (getRequestType(request) != RequestType.UIDL) {
-                // 'plain' http req - e.g. browser reload;
-                // just go ahead redirect the browser
-                response.sendRedirect(ci.getSessionExpiredURL());
-            } else {
+            RequestType requestType = getRequestType(request);
+            if (requestType == RequestType.UIDL) {
                 /*
                  * Invalidate session (weird to have session if we're saying
                  * that it's expired, and worse: portal integration will fail
@@ -846,6 +843,13 @@ public class VaadinServlet extends HttpServlet implements Constants {
                         ci.getSessionExpiredMessage(), null,
                         ci.getSessionExpiredURL());
 
+            } else if (requestType == RequestType.HEARTBEAT) {
+                response.sendError(HttpServletResponse.SC_GONE,
+                        "Session expired");
+            } else {
+                // 'plain' http req - e.g. browser reload;
+                // just go ahead redirect the browser
+                response.sendRedirect(ci.getSessionExpiredURL());
             }
         } catch (SystemMessageException ee) {
             throw new ServletException(ee);
@@ -867,11 +871,8 @@ public class VaadinServlet extends HttpServlet implements Constants {
 
         try {
             SystemMessages ci = getVaadinService().getSystemMessages();
-            if (getRequestType(request) != RequestType.UIDL) {
-                // 'plain' http req - e.g. browser reload;
-                // just go ahead redirect the browser
-                response.sendRedirect(ci.getCommunicationErrorURL());
-            } else {
+            RequestType requestType = getRequestType(request);
+            if (requestType == RequestType.UIDL) {
                 // send uidl redirect
                 criticalNotification(request, response,
                         ci.getCommunicationErrorCaption(),
@@ -882,6 +883,14 @@ public class VaadinServlet extends HttpServlet implements Constants {
                  * since the session is not created by the portal.
                  */
                 request.getSession().invalidate();
+
+            } else if (requestType == RequestType.HEARTBEAT) {
+                response.sendError(HttpServletResponse.SC_FORBIDDEN,
+                        "Forbidden");
+            } else {
+                // 'plain' http req - e.g. browser reload;
+                // just go ahead redirect the browser
+                response.sendRedirect(ci.getCommunicationErrorURL());
             }
         } catch (SystemMessageException ee) {
             throw new ServletException(ee);