Skip to content

Commit 37de09e

Browse files
committed
debug: recreate change in 12544
1 parent 628c16d commit 37de09e

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

appengine/standard/iap/js/poll.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright Google Inc.
2-
//
1+
// Copyright 2017 Google LLC
2+
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -54,10 +54,21 @@ function sessionRefreshClicked() {
5454

5555
function checkSessionRefresh() {
5656
if (iapSessionRefreshWindow != null && !iapSessionRefreshWindow.closed) {
57-
fetch('/favicon.ico').then(function(response) {
57+
// Attempting to start a new session.
58+
// XMLHttpRequests is used by the server to identify AJAX requests
59+
fetch('/favicon.ico', {
60+
method: "GET",
61+
credentials: 'include',
62+
headers: {
63+
'X-Requested-With': 'XMLHttpRequest'
64+
}
65+
}).then(function(response) {
66+
// Checking if browser has a session for the requested app
5867
if (response.status === 401) {
68+
// No new session detected. Try to get a session again
5969
window.setTimeout(checkSessionRefresh, 500);
6070
} else {
71+
// Session retrieved.
6172
iapSessionRefreshWindow.close();
6273
iapSessionRefreshWindow = null;
6374
}

0 commit comments

Comments
 (0)