XRootD
Loading...
Searching...
No Matches
XrdClHttp::CurlTapeOp Class Reference

#include <XrdClHttpOps.hh>

Inheritance diagram for XrdClHttp::CurlTapeOp:
Collaboration diagram for XrdClHttp::CurlTapeOp:

Public Member Functions

 ~CurlTapeOp () override
void Fail (uint16_t errCode, uint32_t errNum, const std::string &message) override
HttpVerb GetVerb () const override
void ReleaseHandle () override
bool Setup (CURL *curl, CurlWorker &worker) 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 ()
void ExtendDeadline (struct timespec timeout)
bool FinishSetup (CURL *curl)
std::pair< XErrorCode, std::string > GetCallbackError () const
CreateConnCalloutType GetConnCalloutFunc () const
std::string GetCurlErrorMessage () const
CURL * GetCurlHandle () const
OpError GetError () const
std::chrono::steady_clock::time_point GetHeaderExpiry () const
std::chrono::steady_clock::time_point GetOperationExpiry ()
std::unique_ptr< ResponseInfo > GetResponseInfo ()
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< ResponseInfo > MoveResponseInfo ()
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)

Protected Member Functions

 CurlTapeOp (XrdCl::ResponseHandler *handler, const std::string &url, std::unique_ptr< TapeOperation > tape, struct timespec timeout, XrdCl::Log *logger, CreateConnCalloutType callout, HeaderCallout *header_callout)
Protected Member Functions inherited from XrdClHttp::CurlOperation
int FailCallback (XErrorCode ecode, const std::string &emsg)
void SetDone (bool has_failed)
void SetPaused (bool paused)
bool SetupNextRequest (const std::string &url, CurlWorker &worker)
void UpdateBytes (uint64_t bytes)

Additional Inherited Members

Public Types inherited from XrdClHttp::CurlOperation
using HeaderList = std::vector<std::pair<std::string, std::string>>
using HttpVerb = XrdClHttp::HttpVerb
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 Attributes inherited from XrdClHttp::CurlOperation
std::unique_ptr< CURL, void(*)(CURL *)> m_curl
XrdCl::ResponseHandler * m_handler {nullptr}
HeaderCallout * m_header_callout
std::atomic< std::chrono::steady_clock::time_point > m_header_expiry
HeaderParser m_headers
std::vector< std::pair< std::string, std::string > > m_headers_list
XrdCl::Log * m_logger
int m_minimum_rate {m_minimum_transfer_rate}
std::chrono::steady_clock::time_point m_operation_expiry
std::string m_request_url
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 632 of file XrdClHttpOps.hh.

Constructor & Destructor Documentation

◆ ~CurlTapeOp()

CurlTapeOp::~CurlTapeOp ( )
overridedefault

References Fail(), GetVerb(), ReleaseHandle(), Setup(), and Success().

Here is the call graph for this function:

◆ CurlTapeOp()

CurlTapeOp::CurlTapeOp ( XrdCl::ResponseHandler * handler,
const std::string & url,
std::unique_ptr< TapeOperation > tape,
struct timespec timeout,
XrdCl::Log * logger,
CreateConnCalloutType callout,
HeaderCallout * header_callout )
protected

Definition at line 37 of file XrdClHttpOpTape.cc.

41:
42 CurlOperation(handler, url, timeout, logger, callout, header_callout),
43 m_tape(std::move(tape))
44{
45}
CurlOperation(XrdCl::ResponseHandler *handler, const std::string &url, struct timespec timeout, XrdCl::Log *log, CreateConnCalloutType, HeaderCallout *header_callout)

References XrdClHttp::CurlOperation::CurlOperation().

Referenced by XrdClHttp::CurlTapePrepareOp::CurlTapePrepareOp(), and XrdClHttp::CurlTapeQueryOp::CurlTapeQueryOp().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ Fail()

void CurlTapeOp::Fail ( uint16_t errCode,
uint32_t errNum,
const std::string & message )
overridevirtual

Reimplemented from XrdClHttp::CurlOperation.

Definition at line 223 of file XrdClHttpOpTape.cc.

225{
226 std::string detail = message;
227 if(GetStatusCode() >= 400)
228 {
229 detail = RequestDescription() + " failed: "
230 + TapeProblemResponse(GetStatusCode(), m_response);
231 }
232 CurlOperation::Fail(errCode, errNum, detail);
233}
std::string TapeProblemResponse(long statusCode, const std::string &body)

References XrdClHttp::CurlOperation::Fail, XrdClHttp::CurlOperation::GetStatusCode(), and XrdClHttp::TapeProblemResponse().

Referenced by ~CurlTapeOp(), Setup(), and Success().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVerb()

CurlOperation::HttpVerb CurlTapeOp::GetVerb ( ) const
overridevirtual

Implements XrdClHttp::CurlOperation.

Definition at line 236 of file XrdClHttpOpTape.cc.

237{
238 return m_request.method;
239}

Referenced by ~CurlTapeOp().

Here is the caller graph for this function:

◆ ReleaseHandle()

void CurlTapeOp::ReleaseHandle ( )
overridevirtual

Reimplemented from XrdClHttp::CurlOperation.

Definition at line 248 of file XrdClHttpOpTape.cc.

249{
250 if(m_curl == nullptr) return;
251
252 curl_easy_setopt(m_curl.get(), CURLOPT_ERRORBUFFER, nullptr);
253 curl_easy_setopt(m_curl.get(), CURLOPT_WRITEFUNCTION, nullptr);
254 curl_easy_setopt(m_curl.get(), CURLOPT_WRITEDATA, nullptr);
255 curl_easy_setopt(m_curl.get(), CURLOPT_HTTPHEADER, nullptr);
256 curl_easy_setopt(m_curl.get(), CURLOPT_POST, 0L);
257 curl_easy_setopt(m_curl.get(), CURLOPT_POSTFIELDS, nullptr);
258 curl_easy_setopt(m_curl.get(), CURLOPT_POSTFIELDSIZE_LARGE,
259 static_cast<curl_off_t>(0));
260 curl_easy_setopt(m_curl.get(), CURLOPT_CUSTOMREQUEST, nullptr);
262}
std::unique_ptr< CURL, void(*)(CURL *)> m_curl
virtual void ReleaseHandle()

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

Referenced by ~CurlTapeOp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Setup()

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

Reimplemented from XrdClHttp::CurlOperation.

Definition at line 74 of file XrdClHttpOpTape.cc.

75{
76 const auto failure = [&](uint16_t code, uint32_t error,
77 const std::string &message) {
78 if(!m_curl) m_curl.reset(curl);
79 Fail(code, error, message);
80 return false;
81 };
82
83 try
84 {
85 const auto status = m_tape->Start(m_request);
86 if(!status.IsOK())
87 {
88 return failure(status.code, status.errNo,
89 status.GetErrorMessage());
90 }
91
92 m_request_url = m_request.url;
93 if(!CurlOperation::Setup(curl, worker))
94 {
95 throw std::runtime_error(
96 "failed to initialize " + RequestDescription());
97 }
98 m_worker = &worker;
99 if(!ConfigureRequest())
100 {
101 throw std::runtime_error(
102 "failed to configure " + RequestDescription());
103 }
104 return true;
105 }
106 catch(const std::exception &ex)
107 {
108 return failure(XrdCl::errInternal, EIO, ex.what());
109 }
110}
virtual bool Setup(CURL *curl, CurlWorker &)
void Fail(uint16_t errCode, uint32_t errNum, const std::string &message) override
const uint16_t errInternal
Internal error.

References XrdCl::errInternal, Fail(), XrdClHttp::CurlOperation::m_curl, XrdClHttp::CurlOperation::m_request_url, and XrdClHttp::CurlOperation::Setup().

Referenced by ~CurlTapeOp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Success()

void CurlTapeOp::Success ( )
overridevirtual

Implements XrdClHttp::CurlOperation.

Definition at line 173 of file XrdClHttpOpTape.cc.

174{
175 try
176 {
177 TapeHttpRequest nextRequest;
178 std::string response;
179 bool complete = false;
180 const auto status = m_tape->Advance(
181 m_curl.get(), GetStatusCode(), m_response,
182 nextRequest, response, complete);
183 if(!status.IsOK())
184 {
185 Fail(status.code, status.errNo, status.GetErrorMessage());
186 return;
187 }
188 if(complete)
189 {
190 Complete(response);
191 return;
192 }
193
194 m_request = std::move(nextRequest);
195 if(!m_worker)
196 {
197 throw std::runtime_error(
198 "worker unavailable before starting " + RequestDescription());
199 }
200 if(!SetupNextRequest(m_request.url, *m_worker))
201 {
202 throw std::runtime_error(
203 "failed to reset the curl handle for " + RequestDescription());
204 }
205 if(!ConfigureRequest())
206 {
207 throw std::runtime_error(
208 "failed to configure " + RequestDescription());
209 }
210 if(!FinishSetup(m_curl.get()))
211 {
212 throw std::runtime_error(
213 "failed to configure headers for " + RequestDescription());
214 }
215 }
216 catch(const std::exception &ex)
217 {
218 Fail(XrdCl::errInternal, EIO, ex.what());
219 }
220}
bool FinishSetup(CURL *curl)
bool SetupNextRequest(const std::string &url, CurlWorker &worker)

References XrdCl::errInternal, Fail(), XrdClHttp::CurlOperation::FinishSetup(), XrdClHttp::CurlOperation::GetStatusCode(), XrdClHttp::CurlOperation::m_curl, and XrdClHttp::CurlOperation::SetupNextRequest().

Referenced by ~CurlTapeOp().

Here is the call graph for this function:
Here is the caller graph for this function:

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