WebDAV: send "User-Agent: SyncEvolution"

Apple iCloud servers reject requests unless they contain a User-Agent
header. The exact value doesn't seem to matter. Making the string
configurable might be better, but can still be done later when it
is more certain whether and for what it is needed.
This commit is contained in:
Patrick Ohly 2014-05-20 16:24:22 +02:00
parent 167f04ef19
commit 1910e5efb3

View file

@ -346,6 +346,12 @@ void Session::preSend(ne_request *req, ne_buffer *header)
SE_THROW("internal error: startOperation() not called");
}
bool haveUserAgentHeader = boost::starts_with(header->data, "User-Agent:") ||
strstr(header->data, "\nUser-Agent:");
if (!haveUserAgentHeader) {
ne_buffer_concat(header, "User-Agent: SyncEvolution\r\n", (const char *)NULL);
}
// Only do this once when using normal username/password.
// Always do it when using OAuth2.
bool useOAuth2 = m_authProvider && m_authProvider->methodIsSupported(AuthProvider::AUTH_METHOD_OAUTH2);