diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-06-12 18:17:37 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-06-22 11:04:52 +0200 |
commit | 1845a8c360f394e7a079bbe9b04ae4a048384962 (patch) | |
tree | 100dbfcf295e8feabed860ca6ceda027a2ca1cfe | |
parent | 755982eda1ed0726f751f0fa38e14580e3766ab6 (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>
(cherry picked from commit b1d18451a459e0b3d0a715fb93f8104413e804df)
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | ucb/source/ucp/webdav/DAVResourceAccess.cxx | 18 |
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" ) ) ) ); } //========================================================================= |