diff --git a/frontend/socketutil.lua b/frontend/socketutil.lua index 1c2c338b2..d73e63956 100644 --- a/frontend/socketutil.lua +++ b/frontend/socketutil.lua @@ -8,6 +8,8 @@ local http = require("socket.http") local https = require("ssl.https") local ltn12 = require("ltn12") local socket = require("socket") +local ffiUtil = require("ffi/util") +local T = ffiUtil.template local socketutil = { -- Init to the default LuaSocket/LuaSec values @@ -15,9 +17,10 @@ local socketutil = { total_timeout = -1, } ---- Builds a sensible UserAgent that fits Wikipedia's UA policy +--- Builds a sensible UserAgent that fits Wikipedia's UA policy local socket_ua = http.USERAGENT -socketutil.USER_AGENT = "KOReader/" .. Version:getShortVersion() .. " (" .. Device.model .. "; " .. jit.os .. "; " .. jit.arch .. ") " .. socket_ua:gsub(" ", "/") +socketutil.USER_AGENT = T("KOReader/%1 (%2; %3; %4; https://github.com/koreader/koreader) %5", + Version:getShortVersion(), Device.model, 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