Conversation
- Add libcurl option to configure script (auto-detected) - Create httpc_curl.c as alternative HTTP client using libcurl - Update Makefile to conditionally use httpc_curl.c when libcurl is enabled - Add ENABLE_CURL conditional fields to http_client struct in http.h - Maintain full API compatibility with existing code - Original httpc.c is used as fallback when libcurl is not available Co-authored-by: Flole998 <9951871+Flole998@users.noreply.github.com>
Co-authored-by: Flole998 <9951871+Flole998@users.noreply.github.com>
- Make libcurl a mandatory dependency (not optional) - Remove old httpc.c custom implementation (2100+ lines of C code) - Rename httpc_curl.c to httpc.c as the sole implementation - Update configure to require libcurl - Update Makefile to remove conditional compilation - Update http.h to remove ENABLE_CURL conditionals - Reduces maintenance burden and bug risk by using well-tested library Co-authored-by: Flole998 <9951871+Flole998@users.noreply.github.com>
- Fix memory leak in realloc failure path - Fix potential buffer overflow in URL construction using dynamic sizing - Fix potential buffer overflow in header construction using dynamic sizing - Remove duplicate ternary expression with local variable - Remove unused hc_ssl field from http_client struct Co-authored-by: Flole998 <9951871+Flole998@users.noreply.github.com>
|
| hc->hc_keepalive = 0; | ||
| } | ||
| http_arg_flush(header); | ||
| curl = curl_easy_init(); |
Check failure
Code scanning / SonarCloud
Weak SSL/TLS protocols should not be used High
| curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); | ||
| curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); | ||
| } else { | ||
| curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); |
Check failure
Code scanning / SonarCloud
Server certificates should be verified during SSL/TLS connections High
| curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); | ||
| } else { | ||
| curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); | ||
| curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); |
Check failure
Code scanning / SonarCloud
Server hostnames should be verified during SSL/TLS connections High




The custom HTTP client implementation (~2100 lines of C) handles socket connections, SSL/TLS, chunked encoding, redirects, and RTSP protocol manually. This creates significant maintenance burden and bug risk. Replace with libcurl.
Changes
Build system: libcurl is now a mandatory dependency
configure: Added libcurl detection, removed optional flagMakefile: Unconditionally link libcurlHTTP client rewrite (
src/httpc.c):http_client_connect,http_client_send,http_client_run, callbacksCURLOPT_RTSP_REQUESTCURLOPT_SSL_VERIFYPEERHeader cleanup (
src/http.h):hc_sslfield (no longer needed)hc_curlandhc_curl_headersfor libcurl handlesENABLE_CURLconditionalsAPI preserved
Result
~1200 fewer lines of code. Delegates socket management, SSL/TLS, redirect handling, and HTTP parsing to a well-tested library.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
239.255.255.250REDACTED, pid is -1(packet block)my.pcloud.com/usr/bin/python /usr/bin/python /home/REDACTED/work/tvheadend/tvheadend/support/pcloud.py publink_download kZ54ee7ZUvsSYmb9VGSpnmoVzcAUhpBXLq8k misc/staticlib/Ubuntu 24.04/x86_64/ffmpeg-45c8a20913aaa75ddec13f3d89c0ce4049850075.tgz /home/REDACTED/work/tvheadend/tvheadend/build.linux/.ffmpeg-45c8a20913aaa75ddec13f3d89c0ce4049850075.tgz.tmp -I adend gnu -D_REENTRANcat .0/include -I adend/build.linux -I in.so /lto-wrapper adend gnu -D_REENTRANtr linux-gnu/dbus-1abcdefghijklmnopqrstuvwxyz -I k/tvheadend/tvheadend/build.linu-o(dns block)/usr/bin/python3 python3 /home/REDACTED/work/tvheadend/tvheadend/support/pcloud.py publink_download kZ54ee7ZUvsSYmb9VGSpnmoVzcAUhpBXLq8k misc/staticlib/Ubuntu 24.04/x86_64/ffmpeg-45c8a20913aaa75ddec13f3d89c0ce4049850075.tgz /home/REDACTED/work/tvheadend/tvheadend/build.linux/.ffmpeg-45c8a20913aaa75ddec13f3d89c0ce4049850075.tgz.tmp -I adend -I .0/include -I adend/build.linux -I adend/src -I ndor/bin/git -I linux-gnu/dbus-1.0/include -I k/tvheadend/tvheadend/build.linux(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.