summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-06-12 18:17:37 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2012-06-12 23:48:52 +0200
commitb1d18451a459e0b3d0a715fb93f8104413e804df (patch)
tree24fa6be62830c621e08252d60074c7ca8707d064
parenta7a4f705904e638f0196e4fd48075bc005d0d43b (diff)
rhbz#678440: Always include User-Agent to avoid 403 from picky servers
(cherry picked from commit 4d0e3127ed2def7212bc05aa860cd06704bb1efe, with modifications) Change-Id: I4fa7b45062b0058427f77cf9dc0abebd6b26fb49 Signed-off-by: Fridrich Štrba <fridrich.strba@bluewin.ch>
-rw-r--r--ucb/source/ucp/webdav/DAVResourceAccess.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.cxx b/ucb/source/ucp/webdav/DAVResourceAccess.cxx
index 11b52518638e..f62ddaf98a33 100644
--- a/ucb/source/ucp/webdav/DAVResourceAccess.cxx
+++ b/ucb/source/ucp/webdav/DAVResourceAccess.cxx
@@ -1151,6 +1151,24 @@ void DAVResourceAccess::getUserRequestHeaders(
}
}
}
+
+ // Make sure a User-Agent header is always included, as at least
+ // en.wikipedia.org:80 forces back 403 "Scripts should use an informative
+ // User-Agent string with contact information, or they may be IP-blocked
+ // without notice" otherwise:
+ for ( DAVRequestHeaders::iterator i(rRequestHeaders.begin());
+ i != rRequestHeaders.end(); ++i )
+ {
+ if ( i->first.equalsIgnoreAsciiCaseAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "User-Agent" ) ) )
+ {
+ return;
+ }
+ }
+ rRequestHeaders.push_back(
+ DAVRequestHeader(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "User-Agent" ) ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LibreOffice" ) ) ) );
}
//=========================================================================