XRootD
Loading...
Searching...
No Matches
XrdClHttp::CurlListdirOp Class Referencefinal

#include <XrdClHttpOps.hh>

Inheritance diagram for XrdClHttp::CurlListdirOp:
Collaboration diagram for XrdClHttp::CurlListdirOp:

Public Member Functions

 CurlListdirOp (XrdCl::ResponseHandler *handler, const std::string &url, const std::string &host_addr, bool response_info, struct timespec timeout, XrdCl::Log *logger, CreateConnCalloutType callout, HeaderCallout *header_callout)
virtual ~CurlListdirOp ()
virtual HttpVerb GetVerb () const override
void ReleaseHandle () override
bool Setup (CURL *curl, CurlWorker &) override
void Success () override
Public Member Functions inherited from XrdClHttp::CurlOperation
 CurlOperation (const CurlOperation &)=delete
 CurlOperation (XrdCl::ResponseHandler *handler, const std::string &url, std::chrono::steady_clock::time_point expiry, XrdCl::Log *log, CreateConnCalloutType, HeaderCallout *header_callout)
 CurlOperation (XrdCl::ResponseHandler *handler, const std::string &url, struct timespec timeout, XrdCl::Log *log, CreateConnCalloutType, HeaderCallout *header_callout)
virtual ~CurlOperation ()
virtual bool ContinueHandle ()
virtual void Fail (uint16_t errCode, uint32_t errNum, const std::string &)
bool FinishSetup (CURL *curl)
std::pair< XErrorCode, std::string > GetCallbackError () const
CreateConnCalloutType GetConnCalloutFunc () const
std::string GetCurlErrorMessage () const
CURLGetCurlHandle () const
OpError GetError () const
std::chrono::steady_clock::time_point GetHeaderExpiry () const
std::chrono::steady_clock::time_point GetOperationExpiry ()
std::unique_ptr< ResponseInfoGetResponseInfo ()
int GetStatusCode () const
std::string GetStatusMessage () const
bool GetTriedBoker () const
const std::string & GetUrl () const
bool HasFailed () const
bool HeaderTimeoutExpired (const std::chrono::steady_clock::time_point &now)
bool IsDone () const
bool IsPaused () const
bool IsRedirect () const
std::unique_ptr< ResponseInfoMoveResponseInfo ()
bool OperationTimeoutExpired (const std::chrono::steady_clock::time_point &now)
virtual void OptionsDone ()
virtual RedirectAction Redirect (std::string &target)
virtual bool RequiresOptions () const
virtual void SetContinueQueue (std::shared_ptr< XrdClHttp::HandlerQueue > queue)
void SetTriedBoker ()
bool StartConnectionCallout (std::string &err)
std::tuple< uint64_t, std::chrono::steady_clock::duration, std::chrono::steady_clock::duration, std::chrono::steady_clock::duration > StatisticsReset ()
bool TransferStalled (uint64_t xfer_bytes, const std::chrono::steady_clock::time_point &now)
bool UseConnectionCallout ()
virtual int WaitSocket ()
virtual int WaitSocketCallback (std::string &err)

Additional Inherited Members

Public Types inherited from XrdClHttp::CurlOperation
using HeaderList = std::vector<std::pair<std::string, std::string>>
enum class  HttpVerb {
  COPY ,
  DELETE ,
  HEAD ,
  GET ,
  MKCOL ,
  OPTIONS ,
  PROPFIND ,
  PUT ,
  Count
}
enum  OpError {
  ErrNone ,
  ErrHeaderTimeout ,
  ErrCallback ,
  ErrOperationTimeout ,
  ErrTransferClientStall ,
  ErrTransferStall ,
  ErrTransferSlow
}
enum class  RedirectAction {
  Fail ,
  Reinvoke ,
  ReinvokeAfterAllow
}
Static Public Member Functions inherited from XrdClHttp::CurlOperation
static void CleanupDnsCache ()
static int GetDefaultSlowRateBytesSec ()
static int GetDefaultStallTimeout ()
static const std::string GetVerbString (HttpVerb)
static void SetSlowRateBytesSec (int rate)
static void SetStallTimeout (const std::chrono::steady_clock::duration &stall_interval)
static void SetStallTimeout (int stall_interval)
Protected Member Functions inherited from XrdClHttp::CurlOperation
int FailCallback (XErrorCode ecode, const std::string &emsg)
void SetDone (bool has_failed)
void SetPaused (bool paused)
void UpdateBytes (uint64_t bytes)
Protected Attributes inherited from XrdClHttp::CurlOperation
std::unique_ptr< CURL, void(*)(CURL *)> m_curl
XrdCl::ResponseHandlerm_handler {nullptr}
HeaderCalloutm_header_callout
std::chrono::steady_clock::time_point m_header_expiry
HeaderParser m_headers
std::vector< std::pair< std::string, std::string > > m_headers_list
XrdCl::Logm_logger
int m_minimum_rate {m_minimum_transfer_rate}
std::chrono::steady_clock::time_point m_operation_expiry
const std::string m_url
Static Protected Attributes inherited from XrdClHttp::CurlOperation
static constexpr int m_default_minimum_rate {1024 * 256}
static int m_minimum_transfer_rate {CurlOperation::m_default_minimum_rate}

Detailed Description

Definition at line 763 of file XrdClHttpOps.hh.

Constructor & Destructor Documentation

◆ CurlListdirOp()

CurlListdirOp::CurlListdirOp ( XrdCl::ResponseHandler * handler,
const std::string & url,
const std::string & host_addr,
bool response_info,
struct timespec timeout,
XrdCl::Log * logger,
CreateConnCalloutType callout,
HeaderCallout * header_callout )

Definition at line 32 of file XrdClHttpOpListdir.cc.

34 :
35 CurlOperation(handler, url, timeout, logger, callout, header_callout),
36 m_response_info(set_response_info),
37 m_host_addr(host_addr)
38{
39 m_minimum_rate = 1024.0 * 1;
40}
CurlOperation(XrdCl::ResponseHandler *handler, const std::string &url, struct timespec timeout, XrdCl::Log *log, CreateConnCalloutType, HeaderCallout *header_callout)

References XrdClHttp::CurlOperation::CurlOperation(), and XrdClHttp::CurlOperation::m_minimum_rate.

Here is the call graph for this function:

◆ ~CurlListdirOp()

virtual XrdClHttp::CurlListdirOp::~CurlListdirOp ( )
inlinevirtual

Definition at line 768 of file XrdClHttpOps.hh.

768{}

Member Function Documentation

◆ GetVerb()

virtual HttpVerb XrdClHttp::CurlListdirOp::GetVerb ( ) const
inlineoverridevirtual

◆ ReleaseHandle()

void CurlListdirOp::ReleaseHandle ( )
overridevirtual

Reimplemented from XrdClHttp::CurlOperation.

Definition at line 55 of file XrdClHttpOpListdir.cc.

56{
57 if (m_curl == nullptr) return;
58 curl_easy_setopt(m_curl.get(), CURLOPT_WRITEFUNCTION, nullptr);
59 curl_easy_setopt(m_curl.get(), CURLOPT_WRITEDATA, nullptr);
60 curl_easy_setopt(m_curl.get(), CURLOPT_CUSTOMREQUEST, nullptr);
61 curl_easy_setopt(m_curl.get(), CURLOPT_HTTPHEADER, nullptr);
63}
std::unique_ptr< CURL, void(*)(CURL *)> m_curl
virtual void ReleaseHandle()

References XrdClHttp::CurlOperation::m_curl, and XrdClHttp::CurlOperation::ReleaseHandle().

Here is the call graph for this function:

◆ Setup()

bool CurlListdirOp::Setup ( CURL * curl,
CurlWorker & worker )
overridevirtual

Reimplemented from XrdClHttp::CurlOperation.

Definition at line 43 of file XrdClHttpOpListdir.cc.

44{
45 if (!CurlOperation::Setup(curl, worker)) return false;
46 curl_easy_setopt(m_curl.get(), CURLOPT_WRITEFUNCTION, CurlListdirOp::WriteCallback);
47 curl_easy_setopt(m_curl.get(), CURLOPT_WRITEDATA, this);
48 curl_easy_setopt(m_curl.get(), CURLOPT_CUSTOMREQUEST, "PROPFIND");
49 m_headers_list.emplace_back("Depth", "1");
50
51 return true;
52}
std::vector< std::pair< std::string, std::string > > m_headers_list
virtual bool Setup(CURL *curl, CurlWorker &)

References XrdClHttp::CurlOperation::m_curl, XrdClHttp::CurlOperation::m_headers_list, and XrdClHttp::CurlOperation::Setup().

Here is the call graph for this function:

◆ Success()

void CurlListdirOp::Success ( )
overridevirtual

Implements XrdClHttp::CurlOperation.

Definition at line 168 of file XrdClHttpOpListdir.cc.

169{
170 SetDone(false);
171 m_logger->Debug(kLogXrdClHttp, "CurlListdirOp::Success");
172
173 std::unique_ptr<XrdCl::DirectoryList> dirlist(m_response_info ? new DirectoryListResponse() : new XrdCl::DirectoryList());
174
175 TiXmlDocument doc;
176 doc.Parse(m_response.c_str());
177 if (doc.Error()) {
178 m_logger->Error(kLogXrdClHttp, "Failed to parse XML response: %s", m_response.substr(0, 1024).c_str());
179 Fail(XrdCl::errErrorResponse, kXR_FSError, "Server responded to directory listing with invalid XML");
180 return;
181 }
182
183 auto elem = doc.RootElement();
184 if (strcasecmp(elem->Value(), "D:multistatus")) {
185 m_logger->Error(kLogXrdClHttp, "Unexpected XML response: %s", m_response.substr(0, 1024).c_str());
186 Fail(XrdCl::errErrorResponse, kXR_FSError, "Server responded to directory listing unexpected XML root");
187 return;
188 }
189 bool skip = true;
190 for (auto response = elem->FirstChildElement(); response != nullptr; response = response->NextSiblingElement()) {
191 if (strcasecmp(response->Value(), "D:response")) {
192 continue;
193 }
194
195 auto [entry, success] = ParseResponse(response);
196 if (!success) {
197 m_logger->Error(kLogXrdClHttp, "Failed to parse response element in XML response: %s", m_response.substr(0, 1024).c_str());
198 Fail(XrdCl::errErrorResponse, kXR_FSError, "Server responded with invalid directory listing");
199 return;
200 }
201 // Skip the first entry in the response, which is the directory itself
202 if (skip) {
203 skip = false;
204 } else {
205 uint32_t flags = XrdCl::StatInfo::Flags::IsReadable;
206 if (entry.m_isdir) {
208 }
209 if (entry.m_isexec) {
211 }
212 dirlist->Add(new XrdCl::DirectoryList::ListEntry(m_host_addr, entry.m_name, new XrdCl::StatInfo("nobody", entry.m_size, flags, entry.m_lastmodified)));
213 }
214 }
215
216 m_logger->Debug(kLogXrdClHttp, "Successful propfind directory listing operation on %s (%u items)", m_url.c_str(), static_cast<unsigned>(dirlist->GetSize()));
217 if (m_handler == nullptr) {return;}
218
219 if (m_response_info) {
220 static_cast<DirectoryListResponse*>(dirlist.get())->SetResponseInfo(MoveResponseInfo());
221 }
222 auto obj = new XrdCl::AnyObject();
223 obj->Set(dirlist.release());
224
225 auto handle = m_handler;
226 m_handler = nullptr;
227 handle->HandleResponse(new XrdCl::XRootDStatus(), obj);
228}
@ kXR_FSError
void SetDone(bool has_failed)
std::unique_ptr< ResponseInfo > MoveResponseInfo()
const std::string m_url
virtual void Fail(uint16_t errCode, uint32_t errNum, const std::string &)
XrdCl::ResponseHandler * m_handler
@ IsReadable
Read access is allowed.
@ IsDir
This is a directory.
@ XBitSet
Executable/searchable bit set.
const uint64_t kLogXrdClHttp
const uint16_t errErrorResponse

References XrdCl::errErrorResponse, XrdClHttp::CurlOperation::Fail(), XrdCl::StatInfo::IsDir, XrdCl::StatInfo::IsReadable, XrdClHttp::kLogXrdClHttp, kXR_FSError, XrdClHttp::CurlOperation::m_handler, XrdClHttp::CurlOperation::m_logger, XrdClHttp::CurlOperation::m_url, XrdClHttp::CurlOperation::MoveResponseInfo(), XrdClHttp::CurlOperation::SetDone(), XrdClHttp::DirectoryListResponse::SetResponseInfo(), and XrdCl::StatInfo::XBitSet.

Here is the call graph for this function:

The documentation for this class was generated from the following files: