Browse Source

Add a User-Agent http header to curl requests

tags/2021-05-28
hogliux 9 years ago
parent
commit
f83554c966
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      modules/juce_core/native/juce_curl_Network.cpp

+ 7
- 1
modules/juce_core/native/juce_curl_Network.cpp View File

@@ -133,10 +133,16 @@ private:
const int maxRedirects, const String& headers,
bool isPost, const String& httpRequest, size_t postSize)
{
curl_version_info_data* data = curl_version_info (CURLVERSION_NOW);
jassert (data != nullptr);
String userAgent = String ("curl/") + data->version;
if (curl_easy_setopt (curl, CURLOPT_URL, address.toRawUTF8()) == CURLE_OK
&& curl_easy_setopt (curl, CURLOPT_WRITEDATA, this) == CURLE_OK
&& curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, StaticCurlWrite) == CURLE_OK
&& curl_easy_setopt (curl, CURLOPT_MAXREDIRS, static_cast<long> (maxRedirects)) == CURLE_OK)
&& curl_easy_setopt (curl, CURLOPT_MAXREDIRS, static_cast<long> (maxRedirects)) == CURLE_OK
&& curl_easy_setopt (curl, CURLOPT_USERAGENT, userAgent.toRawUTF8()) == CURLE_OK)
{
if (isPost)
{


Loading…
Cancel
Save