Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More compact default user-agent.

Resembles a Web browser. Included Mac OS specific variant.
Is less likely to be blocked as an undesired agent/content scraper/spambot.
(Sorry, including a URL is like admitting that the agent is up to no good.)
  • Loading branch information...
commit 02d90d25f717e6578b8c0ad21af47cd79fdb3709 1 parent 9e2e356
@Aeyoun Aeyoun authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/utils.cpp
View
10 src/utils.cpp
@@ -540,7 +540,15 @@ std::string utils::get_useragent(configcontainer * cfgcont) {
if (ua_pref.length() == 0) {
struct utsname buf;
uname(&buf);
- return utils::strprintf("%s/%s (%s %s; %s; %s) %s", PROGRAM_NAME, PROGRAM_VERSION, buf.sysname, buf.release, buf.machine, PROGRAM_URL, curl_version());
+ if (strcmp(buf.sysname, "Darwin") == 0) {
+ /* Assume it is a Mac from the last decade or at least Mac-like */
+ const char* PROCESSOR = "";
+ if (strcmp(buf.machine, "x86_64") == 0 || strcmp(buf.machine, "i386") == 0) {
+ PROCESSOR = "Intel ";
+ }
+ return utils::strprintf("%s/%s (Macintosh; %sMac OS X)", PROGRAM_NAME, PROGRAM_VERSION, PROCESSOR);
+ }
+ return utils::strprintf("%s/%s (%s %s)", PROGRAM_NAME, PROGRAM_VERSION, buf.sysname, buf.machine);
}
return ua_pref;
}
Please sign in to comment.
Something went wrong with that request. Please try again.