f88af95552
It turns out that every single client of InternetProxyDecider simply concatenates the 2 members of InternetProxyServer into a single string and passes it on to curl_easy_setopt(CURLOPT_PROXY), which will happily take a URL including scheme and everything. It turns out that the awful GetUnixSystemProxy() tries to cut off the scheme in a terrible way, but GetPACProxy() does no such thing and WINHTTP_PROXY_INFO::lpszProxy may or may not contain scheme in its entries; fix this to only separate the port and leave the rest alone. So why do we need a InternetProxyServer struct? Because officecfg has separate entries that correspond to its members, and so InternetProxyDecider gets separate events on its listener interface when any of them changes, which is easiest to handle if it stores these separately. So just return a concatenated URL with or without scheme in getProxy(). Change-Id: I43c696471c8bec90667b5930fa00975adb432fe1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155840 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
145 lines
6.4 KiB
C++
145 lines
6.4 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "DAVSession.hxx"
|
|
#include "CurlUri.hxx"
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <atomic>
|
|
#include <mutex>
|
|
|
|
namespace http_dav_ucp
|
|
{
|
|
/// implementation of libcurl HTTP/DAV back-end
|
|
class CurlSession : public DAVSession
|
|
{
|
|
private:
|
|
/// mutex required to access all other non-const members
|
|
::std::mutex m_Mutex;
|
|
css::uno::Reference<css::uno::XComponentContext> const m_xContext;
|
|
/// flags may be passed to constructor, e.g. "KeepAlive"
|
|
css::uno::Sequence<css::beans::NamedValue> const m_Flags;
|
|
CurlUri const m_URI;
|
|
/// buffer for libcurl detailed error messages
|
|
char m_ErrorBuffer[CURL_ERROR_SIZE];
|
|
/// proxy is used if non-empty
|
|
OUString const m_Proxy;
|
|
/// once authentication was successful, rely on m_pCurl's data
|
|
bool m_isAuthenticated = false;
|
|
bool m_isAuthenticatedProxy = false;
|
|
/// read timeout in milliseconds (connection timeout is stored in m_pCurl)
|
|
int m_nReadTimeout = 0;
|
|
/// flag to signal abort to transferring thread
|
|
::std::atomic<bool> m_AbortFlag = false;
|
|
|
|
/// libcurl multi handle
|
|
::std::unique_ptr<CURLM, deleter_from_fn<CURLM, curl_multi_cleanup>> m_pCurlMulti;
|
|
/// libcurl easy handle
|
|
::std::unique_ptr<CURL, deleter_from_fn<CURL, curl_easy_cleanup>> m_pCurl;
|
|
|
|
// this class exists just to hide the implementation details in cxx file
|
|
friend struct CurlProcessor;
|
|
|
|
public:
|
|
explicit CurlSession(css::uno::Reference<css::uno::XComponentContext> xContext,
|
|
::rtl::Reference<DAVSessionFactory> const& rpFactory, OUString const& rURI,
|
|
css::uno::Sequence<css::beans::NamedValue> const& rFlags,
|
|
::ucbhelper::InternetProxyDecider const& rProxyDecider);
|
|
virtual ~CurlSession() override;
|
|
|
|
virtual auto CanUse(OUString const& rURI,
|
|
css::uno::Sequence<css::beans::NamedValue> const& rFlags) -> bool override;
|
|
|
|
virtual auto UsesProxy() -> bool override;
|
|
|
|
// DAV methods
|
|
virtual auto OPTIONS(OUString const& rURIReference, DAVOptions& rOptions,
|
|
DAVRequestEnvironment const& rEnv) -> void override;
|
|
|
|
virtual auto PROPFIND(OUString const& rURIReference, Depth depth,
|
|
::std::vector<OUString> const& rPropertyNames,
|
|
::std::vector<DAVResource>& o_rResources,
|
|
DAVRequestEnvironment const& rEnv) -> void override;
|
|
|
|
virtual auto PROPFIND(OUString const& rURIReference, Depth depth,
|
|
::std::vector<DAVResourceInfo>& o_rResourceInfos,
|
|
DAVRequestEnvironment const& rEnv) -> void override;
|
|
|
|
virtual auto PROPPATCH(OUString const& rURIReference,
|
|
::std::vector<ProppatchValue> const& rValues,
|
|
DAVRequestEnvironment const& rEnv) -> void override;
|
|
|
|
virtual auto HEAD(OUString const& rURIReference, ::std::vector<OUString> const& rHeaderNames,
|
|
DAVResource& io_rResource, DAVRequestEnvironment const& rEnv)
|
|
-> void override;
|
|
|
|
virtual auto GET(OUString const& rURIReference, DAVRequestEnvironment const& rEnv)
|
|
-> css::uno::Reference<css::io::XInputStream> override;
|
|
|
|
virtual auto GET(OUString const& rURIReference,
|
|
css::uno::Reference<css::io::XOutputStream>& rxOutStream,
|
|
DAVRequestEnvironment const& rEnv) -> void override;
|
|
|
|
virtual auto GET(OUString const& rURIReference, ::std::vector<OUString> const& rHeaderNames,
|
|
DAVResource& io_rResource, DAVRequestEnvironment const& rEnv)
|
|
-> css::uno::Reference<css::io::XInputStream> override;
|
|
|
|
virtual auto GET(OUString const& rURIReference,
|
|
css::uno::Reference<css::io::XOutputStream>& rxOutStream,
|
|
::std::vector<OUString> const& rHeaderNames, DAVResource& io_rResource,
|
|
DAVRequestEnvironment const& rEnv) -> void override;
|
|
|
|
virtual auto PUT(OUString const& rURIReference,
|
|
css::uno::Reference<css::io::XInputStream> const& rxInStream,
|
|
DAVRequestEnvironment const& rEnv) -> void override;
|
|
|
|
virtual auto POST(OUString const& rURIReference, OUString const& rContentType,
|
|
OUString const& rReferer,
|
|
css::uno::Reference<css::io::XInputStream> const& rxInStream,
|
|
DAVRequestEnvironment const& rEnv)
|
|
-> css::uno::Reference<css::io::XInputStream> override;
|
|
|
|
virtual auto POST(OUString const& rURIReference, OUString const& rContentType,
|
|
OUString const& rReferer,
|
|
css::uno::Reference<css::io::XInputStream> const& rxInStream,
|
|
css::uno::Reference<css::io::XOutputStream>& rxOutStream,
|
|
DAVRequestEnvironment const& rEnv) -> void override;
|
|
|
|
virtual auto MKCOL(OUString const& rURIReference, DAVRequestEnvironment const& rEnv)
|
|
-> void override;
|
|
|
|
virtual auto COPY(OUString const& rSourceURIReference, OUString const& rDestinationURI,
|
|
DAVRequestEnvironment const& rEnv, bool isOverwrite = false) -> void override;
|
|
|
|
virtual auto MOVE(OUString const& rSourceURIReference, OUString const& rDestinationURI,
|
|
DAVRequestEnvironment const& rEnv, bool isOverwrite = false) -> void override;
|
|
|
|
virtual auto DESTROY(OUString const& rURIReference, DAVRequestEnvironment const& rEnv)
|
|
-> void override;
|
|
|
|
virtual auto LOCK(OUString const& rURIReference, css::ucb::Lock /*const*/& rLock,
|
|
DAVRequestEnvironment const& rEnv) -> void override;
|
|
|
|
virtual auto UNLOCK(OUString const& rURIReference, DAVRequestEnvironment const& rEnv)
|
|
-> void override;
|
|
|
|
virtual auto abort() -> void override;
|
|
|
|
auto NonInteractive_LOCK(OUString const& rURI, ::std::u16string_view rLockToken,
|
|
sal_Int32& o_rLastChanceToSendRefreshRequest, bool& o_rIsAuthFailed)
|
|
-> bool;
|
|
auto NonInteractive_UNLOCK(OUString const& rURI) -> void;
|
|
};
|
|
|
|
} // namespace http_dav_ucp
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|