mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
socketutil: remove URL from user agent, add device info (#12977)
Some checks are pending
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (10.15, 13, x86-64, 15.2) (push) Waiting to run
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (11.0, 14, ARM64, 15.4) (push) Waiting to run
Some checks are pending
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (10.15, 13, x86-64, 15.2) (push) Waiting to run
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (11.0, 14, ARM64, 15.4) (push) Waiting to run
See #10186, <https://github.com/koreader/koreader/issues/12953#issuecomment-2565973079> Results in: ``` KOReader/2024.11-112 (Emulator; Linux; x64) LuaSocket/3.1.0 ```
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
This module contains miscellaneous helper functions specific to our usage of LuaSocket/LuaSec.
|
||||
]]
|
||||
|
||||
local Device = require("device")
|
||||
local Version = require("version")
|
||||
local http = require("socket.http")
|
||||
local https = require("ssl.https")
|
||||
@@ -16,7 +17,7 @@ local socketutil = {
|
||||
|
||||
--- Builds a sensible UserAgent that fits Wikipedia's UA policy <https://meta.wikimedia.org/wiki/User-Agent_policy>
|
||||
local socket_ua = http.USERAGENT
|
||||
socketutil.USER_AGENT = "KOReader/" .. Version:getShortVersion() .. " (https://koreader.rocks/) " .. socket_ua:gsub(" ", "/")
|
||||
socketutil.USER_AGENT = "KOReader/" .. Version:getShortVersion() .. " (" .. Device:info() .. "; " .. jit.os .. "; " .. jit.arch .. ") " .. socket_ua:gsub(" ", "/")
|
||||
-- Monkey-patch it in LuaSocket, as it already takes care of inserting the appropriate header to its requests.
|
||||
http.USERAGENT = socketutil.USER_AGENT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user