mirror of
https://github.com/modernw/App-Installer-For-Windows-8.x-Reset.git
synced 2026-04-11 17:57:19 +10:00
Fixed download bug.
This commit is contained in:
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -6542,7 +6542,7 @@ g_HandleSystemReboot();
|
||||
</SessionVar>
|
||||
<SessionVar>
|
||||
<Name>%ProductVer%</Name>
|
||||
<Value>0.2.2.1</Value>
|
||||
<Value>0.2.2.2</Value>
|
||||
<Type>1</Type>
|
||||
</SessionVar>
|
||||
<SessionVar>
|
||||
|
||||
@@ -148,12 +148,7 @@ public ref class DownloadHelper
|
||||
}
|
||||
|
||||
DWORD protocols =
|
||||
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 |
|
||||
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 |
|
||||
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 |
|
||||
WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 |
|
||||
WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 |
|
||||
WINHTTP_FLAG_SECURE_PROTOCOL_ALL;
|
||||
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2;
|
||||
|
||||
WinHttpSetOption (
|
||||
hSession,
|
||||
@@ -183,6 +178,13 @@ public ref class DownloadHelper
|
||||
WINHTTP_NO_REFERER,
|
||||
WINHTTP_DEFAULT_ACCEPT_TYPES,
|
||||
isHttps ? WINHTTP_FLAG_SECURE : 0);
|
||||
DWORD redirect = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
|
||||
WinHttpSetOption (
|
||||
hRequest,
|
||||
WINHTTP_OPTION_REDIRECT_POLICY,
|
||||
&redirect,
|
||||
sizeof (redirect)
|
||||
);
|
||||
|
||||
if (!hRequest)
|
||||
{
|
||||
@@ -191,6 +193,13 @@ public ref class DownloadHelper
|
||||
ReportError (outPath, L"WinHttpOpenRequest failed: " + GetLastErrorString ());
|
||||
return;
|
||||
}
|
||||
LPCWSTR ua = L"Mozilla/5.0 (Windows NT 6.2; Win32; x86) AppInstallerUpdater/1.0";
|
||||
WinHttpAddRequestHeaders (
|
||||
hRequest,
|
||||
(std::wstring (L"User-Agent: ") + ua).c_str (),
|
||||
-1,
|
||||
WINHTTP_ADDREQ_FLAG_ADD
|
||||
);
|
||||
|
||||
if (!WinHttpSendRequest (hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0,
|
||||
WINHTTP_NO_REQUEST_DATA, 0, 0, 0))
|
||||
@@ -207,6 +216,25 @@ public ref class DownloadHelper
|
||||
CancelHttpHandle (hRequest); hRequest = nullptr;
|
||||
CancelHttpHandle (hConnect); hConnect = nullptr;
|
||||
CancelHttpHandle (hSession); hSession = nullptr;
|
||||
DWORD status = 0;
|
||||
DWORD size = sizeof (status);
|
||||
|
||||
WinHttpQueryHeaders (
|
||||
hRequest,
|
||||
WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,
|
||||
NULL,
|
||||
&status,
|
||||
&size,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (status >= 400)
|
||||
{
|
||||
ReportError (outPath,
|
||||
L"HTTP error: " + std::to_wstring (status));
|
||||
return;
|
||||
}
|
||||
|
||||
ReportError (outPath, L"WinHttpReceiveResponse failed: " + GetLastErrorString ());
|
||||
return;
|
||||
}
|
||||
|
||||
174
shared/html/js/string.js
Normal file
174
shared/html/js/string.js
Normal file
@@ -0,0 +1,174 @@
|
||||
// 判断是否已存在,不存在则添加
|
||||
(function() {
|
||||
// 定义判断函数
|
||||
var isDefined = function(value) {
|
||||
// 先用 typeof !== "undefined" 判断
|
||||
if (typeof value !== "undefined") {
|
||||
// 然后用 value !== void 0 判断
|
||||
if (value !== void 0) {
|
||||
// 然后用 value !== null 判断
|
||||
if (value !== null) {
|
||||
// 判断是否不是空文本时再加上 value != ""
|
||||
if (value != "") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// 1. trim 方法
|
||||
if (typeof String.prototype.trim === "undefined") {
|
||||
String.prototype.trim = function() {
|
||||
// 严格按题目要求进行判断
|
||||
if (typeof this !== "undefined" &&
|
||||
this !== void 0 &&
|
||||
this !== null) {
|
||||
return this.replace(/^\s+|\s+$/g, '');
|
||||
}
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
// 2. tolower 方法(小写化)
|
||||
if (typeof String.prototype.tolower === "undefined") {
|
||||
String.prototype.tolower = function() {
|
||||
// 按题目要求进行判断
|
||||
if (!isDefined(this)) {
|
||||
return this;
|
||||
}
|
||||
// 注意:标准的 toLowerCase 方法已经存在
|
||||
// 这里我们实现一个兼容版本
|
||||
var result = '';
|
||||
var charCode;
|
||||
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
charCode = this.charCodeAt(i);
|
||||
// A-Z 的 ASCII 范围是 65-90
|
||||
if (charCode >= 65 && charCode <= 90) {
|
||||
// 转换为小写:加上 32
|
||||
result += String.fromCharCode(charCode + 32);
|
||||
} else {
|
||||
result += this.charAt(i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
// 3. toupper 方法(大写化)
|
||||
if (typeof String.prototype.toupper === "undefined") {
|
||||
String.prototype.toupper = function() {
|
||||
// 按题目要求进行判断
|
||||
if (!isDefined(this)) {
|
||||
return this;
|
||||
}
|
||||
// 注意:标准的 toUpperCase 方法已经存在
|
||||
// 这里我们实现一个兼容版本
|
||||
var result = '';
|
||||
var charCode;
|
||||
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
charCode = this.charCodeAt(i);
|
||||
// a-z 的 ASCII 范围是 97-122
|
||||
if (charCode >= 97 && charCode <= 122) {
|
||||
// 转换为大写:减去 32
|
||||
result += String.fromCharCode(charCode - 32);
|
||||
} else {
|
||||
result += this.charAt(i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
/*
|
||||
if (typeof String.prototype.trim !== "undefined") {
|
||||
var originalTrim = String.prototype.trim;
|
||||
String.prototype.trim = function() {
|
||||
if (!isDefined(this)) {
|
||||
return this;
|
||||
}
|
||||
return originalTrim.call(this);
|
||||
};
|
||||
}
|
||||
*/
|
||||
})();
|
||||
|
||||
(function() {
|
||||
window.safeTrim = function(str) {
|
||||
if (typeof str !== "undefined" &&
|
||||
str !== void 0 &&
|
||||
str !== null &&
|
||||
str != "") {
|
||||
return str.trim();
|
||||
}
|
||||
return str;
|
||||
};
|
||||
window.safeTolower = function(str) {
|
||||
if (typeof str !== "undefined" &&
|
||||
str !== void 0 &&
|
||||
str !== null &&
|
||||
str != "") {
|
||||
if (typeof str.toLowerCase !== "undefined") {
|
||||
return str.toLowerCase();
|
||||
} else if (typeof str.tolower !== "undefined") {
|
||||
return str.tolower();
|
||||
}
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
window.safeToupper = function(str) {
|
||||
if (typeof str !== "undefined" &&
|
||||
str !== void 0 &&
|
||||
str !== null &&
|
||||
str != "") {
|
||||
if (typeof str.toUpperCase !== "undefined") {
|
||||
return str.toUpperCase();
|
||||
} else if (typeof str.toupper !== "undefined") {
|
||||
return str.toupper();
|
||||
}
|
||||
}
|
||||
return str;
|
||||
};
|
||||
String.prototype.safeTrim = function() {
|
||||
return window.safeTrim(this);
|
||||
};
|
||||
String.prototype.safeTolower = function() {
|
||||
return window.safeTolower(this);
|
||||
};
|
||||
String.prototype.safeToupper = function() {
|
||||
return window.safeToupper(this);
|
||||
};
|
||||
})();
|
||||
|
||||
(function() {
|
||||
if (typeof Object.prototype.safeStringMethods === "undefined") {
|
||||
Object.prototype.safeStringMethods = function() {
|
||||
return {
|
||||
safeTrim: function() {
|
||||
return window.safeTrim(this);
|
||||
},
|
||||
safeTolower: function() {
|
||||
return window.safeTolower(this);
|
||||
},
|
||||
safeToupper: function() {
|
||||
return window.safeToupper(this);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
(function(global) {
|
||||
global.nequals = function(swStringLeft, swStringRight) {
|
||||
return (swStringLeft || "").safeTrim().safeTolower() === (swStringRight || "").safeTrim().safeTolower();
|
||||
};
|
||||
global.nempty = function(swString) {
|
||||
return (swString || "").safeTrim().safeTolower() !== "";
|
||||
};
|
||||
global.nstrlen = function(swString) {
|
||||
return (swString || "").safeTrim().safeTolower().length;
|
||||
};
|
||||
})(this);
|
||||
@@ -1 +1 @@
|
||||
0.2.2.1
|
||||
0.2.2.2
|
||||
Reference in New Issue
Block a user