From 8b8e40350cc40e55752ef9e13aca6241498619b0 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Tue, 24 Dec 2024 15:12:25 -0700 Subject: [PATCH] Update the View Headers request headers. https://redmine.stoutner.com/issues/1164 --- .../activities/ViewHeadersActivity.kt | 24 ++++++------ .../GetHeadersBackgroundTask.kt | 39 ++++++++++++------- .../viewmodels/HeadersViewModel.kt | 26 ++++++------- app/src/main/res/values-es/strings.xml | 2 + app/src/main/res/values-it/strings.xml | 2 + app/src/main/res/values-ru/strings.xml | 4 +- 6 files changed, 57 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt index 77b3aef5..b93fc2fd 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt @@ -1,20 +1,20 @@ -/* - * Copyright 2017-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2017-2024 Soren Stoutner * * This file is part of Privacy Browser Android . * - * Privacy Browser Android is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. * - * Privacy Browser Android is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. * - * You should have received a copy of the GNU General Public License - * along with Privacy Browser Android. If not, see . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ package com.stoutner.privacybrowser.activities diff --git a/app/src/main/java/com/stoutner/privacybrowser/backgroundtasks/GetHeadersBackgroundTask.kt b/app/src/main/java/com/stoutner/privacybrowser/backgroundtasks/GetHeadersBackgroundTask.kt index 73b7754b..030acd2b 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/backgroundtasks/GetHeadersBackgroundTask.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/backgroundtasks/GetHeadersBackgroundTask.kt @@ -1,20 +1,20 @@ -/* - * Copyright 2017-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2017-2024 Soren Stoutner * * This file is part of Privacy Browser Android . * - * Privacy Browser Android is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. * - * Privacy Browser Android is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. * - * You should have received a copy of the GNU General Public License - * along with Privacy Browser Android. If not, see . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ package com.stoutner.privacybrowser.backgroundtasks @@ -126,6 +126,7 @@ class GetHeadersBackgroundTask { // Open a connection to the URL. No data is actually sent at this point. val httpUrlConnection = url.openConnection(proxy) as HttpURLConnection + // Set the `Host` header property. httpUrlConnection.setRequestProperty("Host", url.host) @@ -195,14 +196,24 @@ class GetHeadersBackgroundTask { requestHeadersBuilder.append("?1") + // Set the `Sec-Fetch-Dest` header property. + httpUrlConnection.setRequestProperty("Sec-Fetch-Dest", "document") + + // Add the `Sec-Fetch-User` header to the string builder and format the text. + requestHeadersBuilder.append(newLineString) + requestHeadersBuilder.append("Sec-Fetch-Dest", StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + requestHeadersBuilder.append(colonString) + requestHeadersBuilder.append("document") + + // Set the `Accept` header property. - httpUrlConnection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3") + httpUrlConnection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7") // Add the `Accept` header to the string builder and format the text. requestHeadersBuilder.append(newLineString) requestHeadersBuilder.append("Accept", StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) requestHeadersBuilder.append(colonString) - requestHeadersBuilder.append("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3") + requestHeadersBuilder.append("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7") // Set the `Accept-Language` header property. diff --git a/app/src/main/java/com/stoutner/privacybrowser/viewmodels/HeadersViewModel.kt b/app/src/main/java/com/stoutner/privacybrowser/viewmodels/HeadersViewModel.kt index 3fff3263..8899866a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/viewmodels/HeadersViewModel.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/viewmodels/HeadersViewModel.kt @@ -1,20 +1,20 @@ -/* - * Copyright 2020-2023 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2020-2023 Soren Stoutner * - * This file is part of Privacy Browser Android . + * This file is part of Privacy Browser Android . * - * Privacy Browser Android is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. * - * Privacy Browser Android is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. * - * You should have received a copy of the GNU General Public License - * along with Privacy Browser Android. If not, see . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ package com.stoutner.privacybrowser.viewmodels diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 05242908..cb7fc805 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -643,6 +643,8 @@ Ocultar la barra de aplicaciones Ocultar la barra de aplicaciones que contiene la URL. Mostrar bajo los recortes + Mostrar el sitio web bajo los recortes, como las muescas de la cámara. Cuando está opción está activada, Navegador Privado también se dibujará bajo el teclado. +- Al cambiar esta configuración se reiniciará Navegador Privado en Android < 15. Borrar todo Borra cookies, almacenamiento DOM, el logcat y la caché de WebView. A continuación borra manualmente los directorios “app_webview” y “cache”. Borrar cookies diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 7e70bca6..f4eef5ab 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -643,6 +643,8 @@ Nascondi la barra dell\'applicazione Nasconde la barra che contiene l\'URL. Visualizza sotto i ritagli dello schermo + Visualizza il sito web sotto i ritagli dello schermo come quello della fotocamera. + Quando questa impostazione è abilitata, Privacy Browser sarà anche visualizzato sotto la tastiera. La modifica di questa impostazione provocherà il riavvio di Privacy Browser su Android < 15. Elimina tutto Cancella i cookies, il DOM storage, il logcat e la cache di WebView. Cancella completamente le cartelle “app_webview” e “cache”. Elimina i cookie diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index d581f172..b8dff28f 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -639,6 +639,8 @@ Скрыть панель приложения Скрывает панель приложения, которая содержит URL. Отображение под вырезом + Прорисовывать сайт под вырезами, такими как выемки под камеру. Если эта функция включена, Privacy Browser также будет отрисован под клавиатурой. + Изменение этого параметра приведет к перезапуску Privacy Browser для Android < 15. Очистить все Очищает cookie, DOM-хранилище, logcat и кэш WebView. После этого вручную удаляет каталоги "app_webview" и "cache". Очистить cookie @@ -693,4 +695,4 @@ Использование широкого вида просмотра делает стиль некоторых веб-страниц более похожим на сайт для компьютера. Показывать изображения веб-страницы Отключите для экономии трафика. - \ No newline at end of file + -- 2.47.2