#include <XrdTpcState.hh>
Definition at line 21 of file XrdTpcState.hh.
◆ State() [1/3]
Definition at line 24 of file XrdTpcState.hh.
26 m_recv_status_line(
false),
27 m_recv_all_headers(
false),
36 m_is_transfer_state(
true)
Referenced by Duplicate().
◆ State() [2/3]
TPC::State::State |
( |
CURL * |
curl, |
|
|
bool |
tpcForwardCreds |
|
) |
| |
|
inline |
Don't use that constructor if you want to do some transfers.
- Parameters
-
Definition at line 43 of file XrdTpcState.hh.
45 m_recv_status_line(
false),
46 m_recv_all_headers(
false),
55 m_is_transfer_state(
false),
56 tpcForwardCreds(tpcForwardCreds)
58 InstallHandlers(curl);
◆ State() [3/3]
TPC::State::State |
( |
off_t |
start_offset, |
|
|
Stream & |
stream, |
|
|
CURL * |
curl, |
|
|
bool |
push, |
|
|
bool |
tpcForwardCreds |
|
) |
| |
|
inline |
Definition at line 64 of file XrdTpcState.hh.
66 m_recv_status_line(
false),
67 m_recv_all_headers(
false),
69 m_start_offset(start_offset),
76 m_is_transfer_state(
true),
77 tpcForwardCreds(tpcForwardCreds)
79 InstallHandlers(curl);
◆ ~State()
Definition at line 18 of file XrdTpcState.cc.
20 curl_slist_free_all(m_headers);
22 if (m_curl) {curl_easy_setopt(m_curl, CURLOPT_HTTPHEADER, m_headers);}
◆ AvailableBuffers()
int State::AvailableBuffers |
( |
| ) |
const |
◆ BodyTransferInProgress()
bool TPC::State::BodyTransferInProgress |
( |
| ) |
const |
|
inline |
Definition at line 114 of file XrdTpcState.hh.
114 {
return m_offset && (m_offset != m_content_length);}
◆ BytesTransferred()
off_t TPC::State::BytesTransferred |
( |
| ) |
const |
|
inline |
◆ CopyHeaders()
Handle the 'Copy-Headers' feature
Definition at line 95 of file XrdTpcState.cc.
96 struct curl_slist *list = NULL;
97 for (std::map<std::string, std::string>::const_iterator hdr_iter = req.
headers.begin();
100 if (!strcasecmp(hdr_iter->first.c_str(),
"copy-header")) {
101 list = curl_slist_append(list, hdr_iter->second.c_str());
102 m_headers_copy.emplace_back(hdr_iter->second);
105 if (!strncasecmp(hdr_iter->first.c_str(),
"transferheader",14)) {
106 std::stringstream ss;
107 ss << hdr_iter->first.substr(14) <<
": " << hdr_iter->second;
108 list = curl_slist_append(list, ss.str().c_str());
109 m_headers_copy.emplace_back(ss.str());
113 curl_easy_setopt(m_curl, CURLOPT_HTTPHEADER, list);
std::map< std::string, std::string > & headers
References XrdHttpExtReq::headers.
◆ DumpBuffers()
void State::DumpBuffers |
( |
| ) |
const |
◆ Duplicate()
State * State::Duplicate |
( |
| ) |
|
Definition at line 242 of file XrdTpcState.cc.
243 CURL *curl = curl_easy_duphandle(m_curl);
245 throw std::runtime_error(
"Failed to duplicate existing curl handle.");
248 State *state =
new State(0, *m_stream, curl, m_push, tpcForwardCreds);
251 state->m_headers_copy.reserve(m_headers_copy.size());
252 for (std::vector<std::string>::const_iterator header_iter = m_headers_copy.begin();
253 header_iter != m_headers_copy.end();
255 state->m_headers = curl_slist_append(state->m_headers, header_iter->c_str());
256 state->m_headers_copy.push_back(*header_iter);
258 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL);
259 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, state->m_headers);
References State().
◆ Finalize()
◆ Flush()
◆ GetConnectionDescription()
std::string State::GetConnectionDescription |
( |
| ) |
|
Definition at line 294 of file XrdTpcState.cc.
298 #if LIBCURL_VERSION_NUM >= 0x071500
299 char *curl_ip = NULL;
300 CURLcode rc = curl_easy_getinfo(m_curl, CURLINFO_PRIMARY_IP, &curl_ip);
301 if ((rc != CURLE_OK) || !curl_ip) {
305 rc = curl_easy_getinfo(m_curl, CURLINFO_PRIMARY_PORT, &curl_port);
306 if ((rc != CURLE_OK) || !curl_port) {
309 std::stringstream ss;
315 if (NULL == strchr(curl_ip,
':'))
316 ss <<
"tcp:" << curl_ip <<
":" << curl_port;
318 ss <<
"tcp:[" << curl_ip <<
"]:" << curl_port;
◆ GetContentLength()
off_t TPC::State::GetContentLength |
( |
| ) |
const |
|
inline |
◆ GetErrorCode()
int TPC::State::GetErrorCode |
( |
| ) |
const |
|
inline |
◆ GetErrorMessage()
std::string TPC::State::GetErrorMessage |
( |
| ) |
const |
|
inline |
◆ GetHandle()
CURL* TPC::State::GetHandle |
( |
| ) |
const |
|
inline |
◆ GetStatusCode()
int TPC::State::GetStatusCode |
( |
| ) |
const |
|
inline |
◆ Move()
void State::Move |
( |
State & |
other | ) |
|
Definition at line 27 of file XrdTpcState.cc.
29 m_push = other.m_push;
30 m_recv_status_line = other.m_recv_status_line;
31 m_recv_all_headers = other.m_recv_all_headers;
32 m_offset = other.m_offset;
33 m_start_offset = other.m_start_offset;
34 m_status_code = other.m_status_code;
35 m_content_length = other.m_content_length;
36 m_stream = other.m_stream;
37 m_curl = other.m_curl;
38 m_headers = other.m_headers;
39 m_headers_copy = other.m_headers_copy;
40 m_resp_protocol = other.m_resp_protocol;
41 m_is_transfer_state = other.m_is_transfer_state;
42 curl_easy_setopt(m_curl, CURLOPT_HEADERDATA,
this);
43 if (m_is_transfer_state) {
45 curl_easy_setopt(m_curl, CURLOPT_READDATA,
this);
47 curl_easy_setopt(m_curl, CURLOPT_WRITEDATA,
this);
50 tpcForwardCreds = other.tpcForwardCreds;
51 other.m_headers_copy.clear();
53 other.m_headers = NULL;
54 other.m_stream = NULL;
◆ ResetAfterRequest()
void State::ResetAfterRequest |
( |
| ) |
|
Definition at line 118 of file XrdTpcState.cc.
121 m_content_length = -1;
122 m_recv_all_headers =
false;
123 m_recv_status_line =
false;
◆ SetContentLength()
void TPC::State::SetContentLength |
( |
const off_t |
content_length | ) |
|
|
inline |
Definition at line 90 of file XrdTpcState.hh.
90 { m_content_length = content_length; }
◆ SetErrorCode()
void TPC::State::SetErrorCode |
( |
int |
error_code | ) |
|
|
inline |
◆ SetErrorMessage()
void TPC::State::SetErrorMessage |
( |
const std::string & |
error_msg | ) |
|
|
inline |
◆ SetTransferParameters()
void State::SetTransferParameters |
( |
off_t |
offset, |
|
|
size_t |
size |
|
) |
| |
Definition at line 265 of file XrdTpcState.cc.
266 m_start_offset = offset;
268 m_content_length = size;
269 std::stringstream ss;
270 ss << offset <<
"-" << (offset+size-1);
271 curl_easy_setopt(m_curl, CURLOPT_RANGE, ss.str().c_str());
The documentation for this class was generated from the following files: