Skip to content

socketutil: remove URL from user agent, add device info#12977

Merged
Frenzie merged 1 commit into
koreader:masterfrom
Frenzie:user-agent
Jan 1, 2025
Merged

socketutil: remove URL from user agent, add device info#12977
Frenzie merged 1 commit into
koreader:masterfrom
Frenzie:user-agent

Conversation

@Frenzie
Copy link
Copy Markdown
Member

@Frenzie Frenzie commented Jan 1, 2025

Closes #10186, also see #12953 (comment)

Results in:

KOReader/2024.11-112 (Emulator; Linux; x64) LuaSocket/3.1.0

This change is Reviewable

@Frenzie Frenzie added this to the 2025.01 milestone Jan 1, 2025
@Frenzie Frenzie requested a review from NiLuJe January 1, 2025 10:18
See koreader#10186, <koreader#12953 (comment)>

Results in:

```
KOReader/2024.11-112 (Emulator; Linux; x64) LuaSocket/3.1.0
```
Copy link
Copy Markdown
Member

@NiLuJe NiLuJe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really remember why I added the URL in the first place anyway ;p.

@Frenzie Frenzie merged commit 2b59151 into koreader:master Jan 1, 2025
@Frenzie Frenzie deleted the user-agent branch January 1, 2025 13:16
@0bscur3
Copy link
Copy Markdown

0bscur3 commented Jan 2, 2025

This change breaks HTTP calls on Tolino(only tested on my tolino vision 4 hd) devices, because Device:info() returns a multi line string:

/koreader/device/info ()
  function Device:info()

Nb args: 0

Success
Nb returned values: 1
  1: string: ntx_6sl

Betriebssystem: Android KitKat, api 19 auf arm
Build-Variante: rocks

E-Ink Display unterstützt.
Plattform: freescale


Returned values as JSON:
["ntx_6sl\n\nBetriebssystem: Android KitKat, api 19 auf arm\nBuild-Variante: rocks\n\nE-Ink Display unterstützt.\nPlattform: freescale\n"]

This results in invalid headers being send within HTTP requests.

@Frenzie
Copy link
Copy Markdown
Member Author

Frenzie commented Jan 2, 2025

Thanks, indeed that goes far beyond the Device.model I thought it was for (just with the freedom for some custom logic to get something more than just a generic "Android").

function Device:info()
local is_eink, eink_platform = android.isEink()
local product_type = android.getPlatformName()
local common_text = T(_("%1\n\nOS: Android %2, api %3 on %4\nBuild flavor: %5\n"),
android.prop.product, getCodename(), Device.firmware_rev, jit.arch, android.prop.flavor)
local platform_text = ""
if product_type ~= "android" then
platform_text = "\n" .. T(_("Device type: %1"), product_type) .. "\n"
end
local eink_text = ""
if is_eink then
eink_text = "\n" .. T(_("E-ink display supported.\nPlatform: %1"), eink_platform) .. "\n"
end
local wakelocks_text = ""
if android.needsWakelocks() then
wakelocks_text = "\n" .. _("This device needs CPU, screen and touchscreen always on.\nScreen timeout will be ignored while the app is in the foreground!") .. "\n"
end
return common_text..platform_text..eink_text..wakelocks_text
end

Frenzie added a commit that referenced this pull request Jan 2, 2025
Device:info() is multiline on Android, see #12977 (comment)
Frenzie added a commit that referenced this pull request Jan 2, 2025
Device:info() is multiline on Android, see #12977 (comment)
@0bscur3
Copy link
Copy Markdown

0bscur3 commented Jan 3, 2025

I just installed the latest nightly and I can confirm the fix works. Thanks!

0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
See koreader#10186, <koreader#12953 (comment)>

Results in:

```
KOReader/2024.11-112 (Emulator; Linux; x64) LuaSocket/3.1.0
```
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NewsDownloader: cbc rss times out

3 participants