зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1364727 - Prevent libcurl from printing received data to stdout; r=Dexter
By default libcurl prints all the data it receives to stdout. By providing a dummy write function that drops incoming data and setting it via CURLOPT_WRITEFUNCTION we can quiet the pingsender operation entirely. MozReview-Commit-ID: BsgaUWxtLn9 --HG-- extra : rebase_source : 62e7d56206c07fb21886b1431707611225fe5a8a
This commit is contained in:
Родитель
86592cb3ea
Коммит
8dc7c5a2c7
|
@ -12,10 +12,14 @@
|
|||
|
||||
#include "third_party/curl/curl.h"
|
||||
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
namespace PingSender {
|
||||
|
||||
using std::string;
|
||||
|
||||
using mozilla::Unused;
|
||||
|
||||
/**
|
||||
* A simple wrapper around libcurl "easy" functions. Provides RAII opening
|
||||
* and initialization of the curl library
|
||||
|
@ -135,11 +139,23 @@ CurlWrapper::Init()
|
|||
return true;
|
||||
}
|
||||
|
||||
static size_t
|
||||
DummyWriteCallback(char *ptr, size_t size, size_t nmemb, void *userdata)
|
||||
{
|
||||
Unused << ptr;
|
||||
Unused << size;
|
||||
Unused << nmemb;
|
||||
Unused << userdata;
|
||||
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
bool
|
||||
CurlWrapper::Post(const string& url, const string& payload)
|
||||
{
|
||||
easy_setopt(mCurl, CURLOPT_URL, url.c_str());
|
||||
easy_setopt(mCurl, CURLOPT_USERAGENT, kUserAgent);
|
||||
easy_setopt(mCurl, CURLOPT_WRITEFUNCTION, DummyWriteCallback);
|
||||
|
||||
// Build the date header.
|
||||
std::string dateHeader = GenerateDateHeader();
|
||||
|
|
Загрузка…
Ссылка в новой задаче