Alexander Wels has uploaded a new change for review.

Change subject: userportal,webadmin: IE9 header value
......................................................................

userportal,webadmin: IE9 header value

- Fixed issue where IE9 was reporting missing headers as
  blank instead of null. This would cause initialization
  routined to be executed, and that would cause another
  request which would cause the header to be missing again
  and one would end up in an endless loop of requests. The
  patch checks for both null and blank so the loop never
  happens.

Change-Id: I4144a585a1dec1e736d30f7b7b698687543f7936
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1114863
Signed-off-by: Alexander Wels <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/gin/BaseSystemModule.java
A 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/HttpUtils.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/restapi/RestApiSessionManager.java
3 files changed, 25 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/59/31359/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/gin/BaseSystemModule.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/gin/BaseSystemModule.java
index 45ff5b1..641aec3 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/gin/BaseSystemModule.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/gin/BaseSystemModule.java
@@ -14,6 +14,7 @@
 import org.ovirt.engine.ui.common.system.LockInteractionManager;
 import org.ovirt.engine.ui.common.uicommon.ClientAgentType;
 import org.ovirt.engine.ui.common.utils.DynamicMessages;
+import org.ovirt.engine.ui.common.utils.HttpUtils;
 import org.ovirt.engine.ui.frontend.AppErrors;
 import org.ovirt.engine.ui.frontend.Frontend;
 import org.ovirt.engine.ui.frontend.VdsmErrors;
@@ -124,7 +125,7 @@
 
                     @Override
                     public void onResponseReceived(Request request, Response 
response) {
-                        String tokenValue = 
response.getHeader("OVIRT-SSO-TOKEN"); //$NON-NLS-1$
+                        String tokenValue = HttpUtils.getHeader(response, 
"OVIRT-SSO-TOKEN"); //$NON-NLS-1$
                         if (tokenValue != null) {
                             //Login result received.
                             SSOTokenChangeEvent.fire(eventBus, tokenValue);
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/HttpUtils.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/HttpUtils.java
new file mode 100644
index 0000000..7c71e17
--- /dev/null
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/HttpUtils.java
@@ -0,0 +1,21 @@
+package org.ovirt.engine.ui.common.utils;
+
+import com.google.gwt.http.client.Response;
+
+public class HttpUtils {
+
+    // IE9 "empty string on missing header" fix isolated to this method
+    // If allowBlank == true, method may return empty string; otherwise return 
null
+    public static String getHeader(Response response, String headerKey, 
boolean allowBlank) {
+        String value = response.getHeader(headerKey);
+        if (!allowBlank && "".equals(value)) { //$NON-NLS-1$
+            value = null;
+        }
+        return value;
+    }
+
+    // shortcut for allowBlank == false
+    public static String getHeader(Response response, String headerKey) {
+        return getHeader(response, headerKey, false);
+    }
+}
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/restapi/RestApiSessionManager.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/restapi/RestApiSessionManager.java
index e608b11..99603f6 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/restapi/RestApiSessionManager.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/restapi/RestApiSessionManager.java
@@ -4,6 +4,7 @@
 import java.util.logging.Logger;
 
 import org.ovirt.engine.ui.common.system.ClientStorage;
+import org.ovirt.engine.ui.common.utils.HttpUtils;
 import org.ovirt.engine.ui.frontend.Frontend;
 import org.ovirt.engine.ui.frontend.communication.StorageCallback;
 import org.ovirt.engine.ui.frontend.utils.BaseContextPathData;
@@ -152,7 +153,7 @@
             protected void processResponse(Response response) {
                 // Obtain session ID from response header, as we're unable to 
access REST API
                 // JSESSIONID cookie directly (cookie set for different path 
than WebAdmin page)
-                String sessionIdFromHeader = 
response.getHeader(SESSION_ID_HEADER);
+                String sessionIdFromHeader = HttpUtils.getHeader(response, 
SESSION_ID_HEADER);
 
                 if (sessionIdFromHeader != null) {
                     setSessionId(sessionIdFromHeader);


-- 
To view, visit http://gerrit.ovirt.org/31359
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4144a585a1dec1e736d30f7b7b698687543f7936
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Alexander Wels <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to