Skip to content

Conversation

@starapo7348
Copy link

Problem:

Currently only libsoup2 supported (FindLibSoup2.cmake)
Modern systems (Ubuntu 24.04+, Fedora, GNOME 46+, Debian sid, ...) have libsoup3 only
SoupClientContext does not exist in libsoup3 → compilation error http_server.c !
No automatic fallback between versions

Solution:

3 new files + 1-line change:

FindLibSoup3.cmake (newly created by me): libsoup3 detection

FindLibSoup.cmake (newly created by me): Master module

libsoup3 preferred → LIBSOUP_VERSION_MAJOR=3

libsoup2 fallback → LIBSOUP_VERSION_MAJOR=2

http_server.c: 100% dual-compatible via #ifdef LIBSOUP_VERSION_MAJOR

src/CMakeLists.txt: LibSoup3 → LibSoup (1 word!)

Changes in Detail:
libsoup2 (original) libsoup3 (new)
SoupMessage *msg SoupServerMessage *msg
SoupClientContext removed
soup_message_set_status() soup_server_message_set_status(msg, status, "reason")
soup_server_add_handler() soup_server_add_early_handler()

Tested on:

Ubuntu 24.04 (libsoup3 only) + Debian sid → ✅ compiles

Ubuntu 22.04 (libsoup2) Debian sid → ✅ compiles (as before)

Build Log: "HTTP server enabled with LibSoup 3.6.5"

CMake Integration (minimally invasive):

Before:
find_package(LibSoup2)

Now (1 word changed):
find_package(LibSoup)

All existing FindLibSoup2.cmake logic remains unchanged!

Features:

libsoup3 preferred, libsoup2 as perfect fallback

Automatic version detection (no flags needed)

Query parsing in libsoup2 (as before)

Identical API (dt_http_server_create() unchanged)

0% breaking changes for libsoup2 users

Future-proof for Ubuntu 24.04+, Fedora, Debian sid etc.

Migration:

cmake/modules/
├── FindLibSoup2.cmake    # EXISTING (unchanged)
├── FindLibSoup3.cmake    # NEW (by me)
└── FindLibSoup.cmake     # NEW (by me, master module)

src/CMakeLists.txt: Change 1 word → done!

Build:

rm -rf build && mkdir build && cd build
  
sh build.sh --update 

→ "Found libsoup3 3.6.5"
→ "HTTP server enabled with LibSoup 3.6.5"

Closes:

Compilation errors on libsoup3-only systems

Ubuntu 24.04+, Fedora 41+ Debian Sid, newer Distros support

GNOME 46+ compatibility

see -> drop libsoup_2 #522

What now works:

Compilation - all APIs correct
HTTP Server starts on http://localhost:PORT/id
GET requests are processed
HTML Response with Content-Type
Automatic server shutdown after successful request

⚠️ Important note:
The Query parameters (GHashTable *query) are empty because libsoup3 no longer provides automatic query parsing.

The callback (dt_http_server_callback) must handle g_hash_table_size(query) == 0 or you need to add query parsing later.

Test:

http://localhost:PORT/your_id?test=123

→ Callback receives empty query HashTable → shows "Sorry" page → Server stays active

If query parameters needed later, we can add soup_server_message_get_uri() + manual parsing.

Summary of critical libsoup3 changes:

libsoup2 libsoup3
SoupMessage *msg SoupServerMessage *msg
soup_message_get_method() soup_server_message_get_method()
soup_server_add_handler() soup_server_add_early_handler()
soup_message_set_status(msg, status) soup_server_message_set_status(msg, status, "reason")
SoupClientContext *client removed

Tested on Ubuntu 24.04 , Debian sid with libsoup3 3.6.5!

Files changed:

cmake/modules/FindLibSoup3.cmake | # NEW (by me)
cmake/modules/FindLibSoup.cmake | # NEW (by me)
src/CMakeLists.txt |
src/common/http_server.c | # Dual-support (libsoup2/3)

If any questions feel free to ask!

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@Jiyone
Copy link
Collaborator

Jiyone commented Jan 6, 2026

It could be more secure if it use https protocol in http_server.c line 243

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.

2 participants