From da50792500732ea7d7002a9d2b2226dbd2da53cd Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Tue, 23 May 2023 23:26:07 +0000 Subject: [PATCH] Avoid chunked content encoding. Some WebViewClient debugging. Doesn't go to a blank screen on android so much. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4314 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- Makefile | 4 ++++ core/core.js | 10 +++++++--- .../com/unprompted/tildefriends/MainActivity.java | 6 ++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 53c70dd6..5e74f754 100644 --- a/Makefile +++ b/Makefile @@ -499,6 +499,10 @@ apkgo: out/TildeFriends-debug.apk @adb shell am start com.unprompted.tildefriends/.MainActivity .PHONY: apkgo +apklog: + @adb logcat *:S tildefriends +.PHONY: apklog + clean: rm -rf $(BUILD_DIR) .PHONY: clean diff --git a/core/core.js b/core/core.js index b209752b..1a8352f6 100644 --- a/core/core.js +++ b/core/core.js @@ -504,7 +504,7 @@ async function staticFileHandler(request, response, blobId, uri) { let id = `${stat.mtime}_${stat.size}`; if (request.headers['if-none-match'] === '"' + id + '"') { - response.writeHead(304, {}); + response.writeHead(304, {'Content-Length': '0'}); response.end(); } else { let data = await File.readFile('core/' + path); @@ -538,7 +538,7 @@ async function staticDirectoryHandler(request, response, directory, uri) { let id = `${stat.mtime}_${stat.size}`; if (request.headers['if-none-match'] === '"' + id + '"') { - response.writeHead(304, {}); + response.writeHead(304, {'Content-Length': '0'}); response.end(); } else { let data = await File.readFile(directory + filename); @@ -626,7 +626,7 @@ async function blobHandler(request, response, blobId, uri) { let id = `${stat.mtime}_${stat.size}`; if (request.headers['if-none-match'] === '"' + id + '"') { - response.writeHead(304, {}); + response.writeHead(304, {'Content-Length': '0'}); response.end(); } else { let data = await File.readFile('core/' + k_static_files[i].path); @@ -664,6 +664,7 @@ async function blobHandler(request, response, blobId, uri) { let id = await new Database(match[1]).get('path:' + match[2]); if (id) { if (request.headers['if-none-match'] === '"' + id + '"') { + headers['Content-Length'] = '0'; response.writeHead(304, headers); response.end(); } else { @@ -676,6 +677,7 @@ async function blobHandler(request, response, blobId, uri) { } } else { if (request.headers['if-none-match'] === '"' + blobId + '"') { + headers['Content-Length'] = '0'; response.writeHead(304, headers); response.end(); } else { @@ -684,6 +686,7 @@ async function blobHandler(request, response, blobId, uri) { } } else { if (request.headers['if-none-match'] === '"' + blobId + '"') { + headers['Content-Length'] = '0'; response.writeHead(304, headers); response.end(); } else { @@ -787,6 +790,7 @@ async function blobHandler(request, response, blobId, uri) { let headers = { 'Access-Control-Allow-Origin': '*', 'Content-Security-Policy': 'sandbox', + 'Content-Length': '0', }; response.writeHead(304, headers); response.end(); diff --git a/src/android/com/unprompted/tildefriends/MainActivity.java b/src/android/com/unprompted/tildefriends/MainActivity.java index 8cbdbc5d..8dae04dd 100644 --- a/src/android/com/unprompted/tildefriends/MainActivity.java +++ b/src/android/com/unprompted/tildefriends/MainActivity.java @@ -159,6 +159,12 @@ public class MainActivity extends Activity { .show(); return true; } + + @Override + public boolean onConsoleMessage(android.webkit.ConsoleMessage consoleMessage) { + Log.d("tildefriends", consoleMessage.message() + " -- From line " + consoleMessage.lineNumber() + " of " + consoleMessage.sourceId()); + return true; + } }); web_view.setWebViewClient(new WebViewClient() {