Added connect_timeout configuration to curl input plugin
This commit is contained in:
parent
1429d6bfb9
commit
160f793e2a
@ -223,21 +223,31 @@ variables such as ``http_proxy`` or specified in :file:`~/.curlrc`
|
|||||||
will be in effect.
|
will be in effect.
|
||||||
|
|
||||||
.. list-table::
|
.. list-table::
|
||||||
:widths: 20 80
|
:widths: 20 70 10
|
||||||
:header-rows: 1
|
:header-rows: 1
|
||||||
|
|
||||||
* - Setting
|
* - Setting
|
||||||
- Description
|
- Description
|
||||||
|
- Default
|
||||||
* - **proxy**
|
* - **proxy**
|
||||||
- Sets the address of the HTTP proxy server.
|
- Sets the address of the HTTP proxy server.
|
||||||
|
-
|
||||||
* - **proxy_user, proxy_password**
|
* - **proxy_user, proxy_password**
|
||||||
- Configures proxy authentication.
|
- Configures proxy authentication.
|
||||||
|
-
|
||||||
* - **verify_peer yes|no**
|
* - **verify_peer yes|no**
|
||||||
- Verify the peer's SSL certificate? `More information <http://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html>`_.
|
- Verify the peer's SSL certificate? `More information <http://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html>`_.
|
||||||
|
- yes
|
||||||
* - **verify_host yes|no**
|
* - **verify_host yes|no**
|
||||||
- Verify the certificate's name against host? `More information <http://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html>`_.
|
- Verify the certificate's name against host? `More information <http://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html>`_.
|
||||||
|
- yes
|
||||||
* - **cacert**
|
* - **cacert**
|
||||||
- Set path to Certificate Authority (CA) bundle `More information <https://curl.se/libcurl/c/CURLOPT_CAINFO.html>`_.
|
- Set path to Certificate Authority (CA) bundle `More information <https://curl.se/libcurl/c/CURLOPT_CAINFO.html>`_.
|
||||||
|
-
|
||||||
|
* - **connect_timeout**
|
||||||
|
- Set the the connect phase timeout in seconds. "0" is `libcurl`'s default built-in connection timeout - 300 seconds.
|
||||||
|
`More information <https://curl.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html>`_.
|
||||||
|
- 10
|
||||||
|
|
||||||
ffmpeg
|
ffmpeg
|
||||||
------
|
------
|
||||||
|
@ -151,6 +151,9 @@ static const char *cacert;
|
|||||||
|
|
||||||
static bool verify_peer, verify_host;
|
static bool verify_peer, verify_host;
|
||||||
|
|
||||||
|
/** Connection settings */
|
||||||
|
static long connect_timeout;
|
||||||
|
|
||||||
static CurlInit *curl_init;
|
static CurlInit *curl_init;
|
||||||
|
|
||||||
static constexpr Domain curl_domain("curl");
|
static constexpr Domain curl_domain("curl");
|
||||||
@ -374,6 +377,11 @@ input_curl_init(EventLoop &event_loop, const ConfigBlock &block)
|
|||||||
cacert = block.GetBlockValue("cacert");
|
cacert = block.GetBlockValue("cacert");
|
||||||
verify_peer = block.GetBlockValue("verify_peer", default_verify);
|
verify_peer = block.GetBlockValue("verify_peer", default_verify);
|
||||||
verify_host = block.GetBlockValue("verify_host", default_verify);
|
verify_host = block.GetBlockValue("verify_host", default_verify);
|
||||||
|
|
||||||
|
constexpr unsigned default_connection_timeout = 10;
|
||||||
|
unsigned timeout = block.GetBlockValue("connect_timeout",
|
||||||
|
default_connection_timeout);
|
||||||
|
connect_timeout = static_cast<long>(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -399,7 +407,7 @@ CurlInputStream::CurlInputStream(EventLoop &event_loop, const char *_url,
|
|||||||
request_headers.Append("Icy-Metadata: 1");
|
request_headers.Append("Icy-Metadata: 1");
|
||||||
|
|
||||||
for (const auto &[key, header] : headers)
|
for (const auto &[key, header] : headers)
|
||||||
request_headers.Append((key + ":" + header).c_str());
|
request_headers.Append((key + ":" += header).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
CurlInputStream::~CurlInputStream() noexcept
|
CurlInputStream::~CurlInputStream() noexcept
|
||||||
@ -439,6 +447,7 @@ CurlInputStream::InitEasy()
|
|||||||
request->SetOption(CURLOPT_HTTPHEADER, request_headers.Get());
|
request->SetOption(CURLOPT_HTTPHEADER, request_headers.Get());
|
||||||
request->SetProxyVerifyPeer(verify_peer);
|
request->SetProxyVerifyPeer(verify_peer);
|
||||||
request->SetProxyVerifyHost(verify_host);
|
request->SetProxyVerifyHost(verify_host);
|
||||||
|
request->SetConnectTimeout(connect_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -130,6 +130,10 @@ public:
|
|||||||
easy.SetOption(CURLOPT_PROXY_SSL_VERIFYPEER, value);
|
easy.SetOption(CURLOPT_PROXY_SSL_VERIFYPEER, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetConnectTimeout(long timeout_seconds) {
|
||||||
|
easy.SetConnectTimeout(timeout_seconds);
|
||||||
|
}
|
||||||
|
|
||||||
void SetNoBody(bool value=true) {
|
void SetNoBody(bool value=true) {
|
||||||
easy.SetNoBody(value);
|
easy.SetNoBody(value);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "Easy.hxx"
|
#include "Easy.hxx"
|
||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
|
|
||||||
namespace Curl {
|
namespace Curl {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user