/* -*- 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/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
void CurlUri::Init()
{ // looks like the result should be the same as the old calculateURI() autoconst oURI(GetURLComponent(*m_pUrl, CURLUPART_URL, CURLUE_OK, CURLU_NO_DEFAULT_PORT));
assert(oURI);
m_URI = *oURI;
autoconst oScheme(GetURLComponent(*m_pUrl, CURLUPART_SCHEME, CURLUE_NO_SCHEME)); if (oScheme)
{
m_Scheme = *oScheme;
} autoconst oUser(GetURLComponent(*m_pUrl, CURLUPART_USER, CURLUE_NO_USER)); if (oUser)
{
m_User = *oUser;
} autoconst oPassWord(GetURLComponent(*m_pUrl, CURLUPART_PASSWORD, CURLUE_NO_PASSWORD)); if (oPassWord)
{
m_Password = *oPassWord;
} autoconst oHost(GetURLComponent(*m_pUrl, CURLUPART_HOST, CURLUE_NO_HOST)); if (oHost)
{
m_Host = *oHost;
} // DAV schemes always have port but Content::transfer() is called with // arbitrary URLs so use CURLUE_NO_PORT autoconst oPort(GetURLComponent(*m_pUrl, CURLUPART_PORT, CURLUE_NO_PORT, CURLU_DEFAULT_PORT)); if (oPort)
{
m_nPort = oPort->toInt32();
}
// note: this used to be added to m_Path because before 2007, ne_uri path contained query/fragment as well :-/ autoconst oQuery(GetURLComponent(*m_pUrl, CURLUPART_QUERY, CURLUE_NO_QUERY)); if (oQuery)
{
m_QueryAndFragment += "?" + *oQuery;
} autoconst oFragment(GetURLComponent(*m_pUrl, CURLUPART_FRAGMENT, CURLUE_NO_FRAGMENT)); if (oFragment)
{
m_QueryAndFragment += "#" + *oFragment;
}
}
CurlUri::CurlUri(::std::u16string_view const rURI)
{ // note: in the old implementation, the rURI would be URI-encoded again // here, apparently because it could actually be an IRI (RFC 3987) and // neon didn't support that - not clear if this is a good idea
m_pUrl.reset(curl_url()); if (!m_pUrl)
{ throw ::std::bad_alloc();
}
// use curl to parse the URI, to get a consistent interpretation if (rURI.find(u'\0') != std::u16string_view::npos)
{ throw DAVException(DAVException::DAV_INVALID_ARG);
}
OString const utf8URI(OUStringToOString(rURI, RTL_TEXTENCODING_UTF8)); auto uc = curl_url_set(m_pUrl.get(), CURLUPART_URL, utf8URI.getStr(), 0); if (uc != CURLUE_OK)
{
SAL_WARN("ucb.ucp.webdav.curl", "curl_url_set failed: " << uc); throw DAVException(DAVException::DAV_INVALID_ARG);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.