summaryrefslogtreecommitdiff
path: root/src/input/plugins
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-01-24 12:52:43 +0100
committerMax Kellermann <max@musicpd.org>2018-07-06 19:07:02 +0200
commit60d5bf0240dea58419edb05198906349e81abbe8 (patch)
tree3811d24f1ec17257b14d7dd8759a6948ac676399 /src/input/plugins
parent41cdc4e14b3d36d70039a7ac1578fe7c898a0bac (diff)
util/StringFormat: new utility library
Diffstat (limited to 'src/input/plugins')
-rw-r--r--src/input/plugins/CurlInputPlugin.cxx21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx
index ea48d299b..6e1cf42f2 100644
--- a/src/input/plugins/CurlInputPlugin.cxx
+++ b/src/input/plugins/CurlInputPlugin.cxx
@@ -34,6 +34,7 @@
#include "IOThread.hxx"
#include "util/ASCII.hxx"
#include "util/StringUtil.hxx"
+#include "util/StringFormat.hxx"
#include "util/NumberParser.hxx"
#include "util/RuntimeError.hxx"
#include "util/Domain.hxx"
@@ -373,13 +374,10 @@ CurlInputStream::InitEasy()
if (proxy_port > 0)
request->SetOption(CURLOPT_PROXYPORT, (long)proxy_port);
- if (proxy_user != nullptr && proxy_password != nullptr) {
- char proxy_auth_str[1024];
- snprintf(proxy_auth_str, sizeof(proxy_auth_str),
- "%s:%s",
- proxy_user, proxy_password);
- request->SetOption(CURLOPT_PROXYUSERPWD, proxy_auth_str);
- }
+ if (proxy_user != nullptr && proxy_password != nullptr)
+ request->SetOption(CURLOPT_PROXYUSERPWD,
+ StringFormat<1024>("%s:%s", proxy_user,
+ proxy_password).c_str());
request->SetOption(CURLOPT_SSL_VERIFYPEER, verify_peer ? 1l : 0l);
request->SetOption(CURLOPT_SSL_VERIFYHOST, verify_host ? 2l : 0l);
@@ -416,11 +414,10 @@ CurlInputStream::SeekInternal(offset_type new_offset)
/* send the "Range" header */
- if (offset > 0) {
- char range[32];
- sprintf(range, "%" PRIoffset "-", offset);
- request->SetOption(CURLOPT_RANGE, range);
- }
+ if (offset > 0)
+ request->SetOption(CURLOPT_RANGE,
+ StringFormat<40>("%" PRIoffset "-",
+ offset).c_str());
StartRequest();
}