XRootD
XrdClHttpOpOptions.cc
Go to the documentation of this file.
1 /******************************************************************************/
2 /* Copyright (C) 2025, Pelican Project, Morgridge Institute for Research */
3 /* */
4 /* This file is part of the XrdClHttp client plugin for XRootD. */
5 /* */
6 /* XRootD is free software: you can redistribute it and/or modify it under */
7 /* the terms of the GNU Lesser General Public License as published by the */
8 /* Free Software Foundation, either version 3 of the License, or (at your */
9 /* option) any later version. */
10 /* */
11 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
12 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
13 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
14 /* License for more details. */
15 /* */
16 /* The copyright holder's institutional names and contributor's names may not */
17 /* be used to endorse or promote products derived from this software without */
18 /* specific prior written permission of the institution or contributor. */
19 /******************************************************************************/
20 
21 #include "XrdClHttpOps.hh"
22 
23 using namespace XrdClHttp;
24 
25 void
26 CurlOptionsOp::Fail(uint16_t errCode, uint32_t errNum, const std::string &etext) {
27  CurlOperation::Fail(errCode, errNum, etext);
28  auto &cache = VerbsCache::Instance();
30  // 405 Method Not Supported; indicates that OPTIONS is not understood so
31  // we assume it's highly unlikely that non-HTTP verbs are supported (like
32  // PROPFIND); however, we don't fail the parent operation.
33  //
34  // Since the OPTIONS command is considered advisory, we ignore failures.
35 }
36 
37 bool
39  if (!CurlOperation::Setup(curl, worker)) return false;
40  curl_easy_setopt(m_curl.get(), CURLOPT_CUSTOMREQUEST, "OPTIONS");
41  curl_easy_setopt(m_curl.get(), CURLOPT_NOBODY, 1L);
42 
43  return true;
44 }
45 
46 void
48  auto &cache = VerbsCache::Instance();
49  cache.Put(m_url, m_headers.GetAllowedVerbs());
50 }
51 
52 void
54 {
55  if (m_curl == nullptr) return;
56  curl_easy_setopt(m_curl.get(), CURLOPT_CUSTOMREQUEST, nullptr);
57  curl_easy_setopt(m_curl.get(), CURLOPT_NOBODY, 0L);
59 }
void CURL
const std::string m_url
std::unique_ptr< CURL, void(*)(CURL *)> m_curl
virtual void Fail(uint16_t errCode, uint32_t errNum, const std::string &)
virtual void ReleaseHandle()
virtual bool Setup(CURL *curl, CurlWorker &)
bool Setup(CURL *curl, CurlWorker &) override
void Fail(uint16_t errCode, uint32_t errNum, const std::string &) override
VerbsCache::HttpVerbs GetAllowedVerbs() const
static VerbsCache & Instance()