XRootD
Loading...
Searching...
No Matches
XrdClHttpConnectionCallout.hh
Go to the documentation of this file.
1
/***************************************************************
2
*
3
* Copyright (C) 2025, Morgridge Institute for Research
4
*
5
***************************************************************/
6
7
#ifndef XRDCLHTTP_CONNECTIONCALLOUT_HH
8
#define XRDCLHTTP_CONNECTIONCALLOUT_HH
9
10
#include <chrono>
11
#include <string>
12
13
namespace
XrdClHttp
{
14
15
class
ResponseInfo
;
16
17
// A class that indicates whether a separate socket creation callout is
18
// desired for a given request response and, if so, manages the acquisition
19
// of the new socket.
20
//
21
// There are two relevant class methods:
22
// - `BeginCallout`: Start the process of a socket connection callout. Returns
23
// a file descriptor. That file descriptor will be listened on; when it is
24
// ready, the `FinishCallout` method will be invoked.
25
// - `FinishCallout`: The listener socket indicates it has waiting data; finish
26
// the acquisition of the new socket.
27
//
28
// This "listener socket" design is used so a separate thread can generate the
29
// socket and, when ready, interrupt the thread loop. If the expiration time passes
30
// before the socket has a ready read, the object may be deleted.
31
//
32
// Finally, the ConnectionCallout is created by setting the property
33
// `XrdClConnectionCallout` for the relevant `XrdCl::File` or `XrdCl::FileSystem`
34
// to a string that is the serialized hex value of a function pointer with the
35
// following signature:
36
//
37
// XrdClHttp::ConnectionCallout *CreateCallback(const std::string &url,
38
// const XrdClHttp::ResponseInfo &info);
39
//
40
// The function is provided with the URL desired and the response information
41
// leading up to the current request. It must have C linkage. If a callout
42
// is desired, an pointer is returned (the caller owns the memory); otherwise,
43
// return nullptr to indicate the libcurl default connection logic can be used.
44
class
ConnectionCallout
{
45
public
:
46
47
ConnectionCallout
() {}
48
virtual
~ConnectionCallout
() {}
49
ConnectionCallout
(
const
ConnectionCallout
&) =
delete
;
50
51
// Start a request to get a socket connection.
52
// Returns a FD to monitor for reads on success or -1 on failure.
53
// On failure, err is set to the error message.
54
//
55
// - `err`: On error, set to the human-friendly error message.
56
// - `expiration`: The point in time where XrdClHttp will give up on the request and
57
// close the socket.
58
virtual
int
BeginCallout
(std::string &err,
59
std::chrono::steady_clock::time_point &expiration) = 0;
60
61
// Finish the socket connection callout.
62
// Invoked when there is data on the file descriptor provided by `BeginCallout`.
63
//
64
// On success, returns a FD connected to the requested server.
65
// Returns -1 on failure and sets err to the error message.
66
virtual
int
FinishCallout
(std::string &err) = 0;
67
};
68
69
using
CreateConnCalloutType
=
ConnectionCallout
*(*)(
const
std::string &,
const
ResponseInfo
&);
70
71
}
// namespace XrdClHttp
72
73
#endif
// XRDCLHTTP_CONNECTIONCALLOUT_HH
XrdClHttp::ConnectionCallout
Definition
XrdClHttpConnectionCallout.hh:44
XrdClHttp::ConnectionCallout::~ConnectionCallout
virtual ~ConnectionCallout()
Definition
XrdClHttpConnectionCallout.hh:48
XrdClHttp::ConnectionCallout::ConnectionCallout
ConnectionCallout(const ConnectionCallout &)=delete
XrdClHttp::ConnectionCallout::FinishCallout
virtual int FinishCallout(std::string &err)=0
XrdClHttp::ConnectionCallout::ConnectionCallout
ConnectionCallout()
Definition
XrdClHttpConnectionCallout.hh:47
XrdClHttp::ConnectionCallout::BeginCallout
virtual int BeginCallout(std::string &err, std::chrono::steady_clock::time_point &expiration)=0
XrdClHttp::ResponseInfo
Definition
XrdClHttpResponseInfo.hh:18
XrdClHttp
Definition
XrdClHttpChecksum.hh:28
XrdClHttp::CreateConnCalloutType
ConnectionCallout *(*)(const std::string &, const ResponseInfo &) CreateConnCalloutType
Definition
XrdClHttpConnectionCallout.hh:69
XrdClHttp
XrdClHttpConnectionCallout.hh
Generated by
1.15.0