#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),
56 m_is_transfer_state(
false),
57 tpcForwardCreds(tpcForwardCreds)
59 InstallHandlers(curl);
◆ State() [3/3]
TPC::State::State |
( |
off_t |
start_offset, |
|
|
Stream & |
stream, |
|
|
CURL * |
curl, |
|
|
bool |
push, |
|
|
bool |
tpcForwardCreds |
|
) |
| |
|
inline |
Definition at line 65 of file XrdTpcState.hh.
67 m_recv_status_line(
false),
68 m_recv_all_headers(
false),
70 m_start_offset(start_offset),
78 m_is_transfer_state(
true),
79 tpcForwardCreds(tpcForwardCreds)
81 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 116 of file XrdTpcState.hh.
116 {
return m_offset && (m_offset != m_content_length);}
◆ BytesTransferred()
off_t TPC::State::BytesTransferred |
( |
| ) |
const |
|
inline |
◆ DumpBuffers()
void State::DumpBuffers |
( |
| ) |
const |
◆ Duplicate()
State * State::Duplicate |
( |
| ) |
|
Definition at line 260 of file XrdTpcState.cc.
261 CURL *curl = curl_easy_duphandle(m_curl);
263 throw std::runtime_error(
"Failed to duplicate existing curl handle.");
266 State *state =
new State(0, *m_stream, curl, m_push, tpcForwardCreds);
269 state->m_headers_copy.reserve(m_headers_copy.size());
270 for (std::vector<std::string>::const_iterator header_iter = m_headers_copy.begin();
271 header_iter != m_headers_copy.end();
273 state->m_headers = curl_slist_append(state->m_headers, header_iter->c_str());
274 state->m_headers_copy.push_back(*header_iter);
276 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL);
277 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, state->m_headers);
References State().
◆ Finalize()
◆ Flush()
◆ GetConnectionDescription()
std::string State::GetConnectionDescription |
( |
| ) |
|
Definition at line 312 of file XrdTpcState.cc.
316 #if LIBCURL_VERSION_NUM >= 0x071500
317 char *curl_ip = NULL;
318 CURLcode rc = curl_easy_getinfo(m_curl, CURLINFO_PRIMARY_IP, &curl_ip);
319 if ((rc != CURLE_OK) || !curl_ip) {
323 rc = curl_easy_getinfo(m_curl, CURLINFO_PRIMARY_PORT, &curl_port);
324 if ((rc != CURLE_OK) || !curl_port) {
327 std::stringstream ss;
333 if (NULL == strchr(curl_ip,
':'))
334 ss <<
"tcp:" << curl_ip <<
":" << curl_port;
336 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_push_length = other.m_push_length;
37 m_stream = other.m_stream;
38 m_curl = other.m_curl;
39 m_headers = other.m_headers;
40 m_headers_copy = other.m_headers_copy;
41 m_resp_protocol = other.m_resp_protocol;
42 m_is_transfer_state = other.m_is_transfer_state;
43 curl_easy_setopt(m_curl, CURLOPT_HEADERDATA,
this);
44 if (m_is_transfer_state) {
46 curl_easy_setopt(m_curl, CURLOPT_READDATA,
this);
48 curl_easy_setopt(m_curl, CURLOPT_WRITEDATA,
this);
51 tpcForwardCreds = other.tpcForwardCreds;
52 other.m_headers_copy.clear();
54 other.m_headers = NULL;
55 other.m_stream = NULL;
◆ ResetAfterRequest()
void State::ResetAfterRequest |
( |
| ) |
|
Definition at line 135 of file XrdTpcState.cc.
138 m_content_length = -1;
140 m_recv_all_headers =
false;
141 m_recv_status_line =
false;
◆ SetContentLength()
void TPC::State::SetContentLength |
( |
const off_t |
content_length | ) |
|
|
inline |
Definition at line 92 of file XrdTpcState.hh.
92 { 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 283 of file XrdTpcState.cc.
284 m_start_offset = offset;
286 m_content_length = size;
287 std::stringstream ss;
288 ss << offset <<
"-" << (offset+size-1);
289 curl_easy_setopt(m_curl, CURLOPT_RANGE, ss.str().c_str());
◆ SetupHeaders()
Setup any headers necessary for the GET/PUT operation
Currently includes:
- Handle the 'Copy-Headers' feature
- Adding
Expect: 100-continue
to get around a libcurl bug on uploads.
Definition at line 101 of file XrdTpcState.cc.
102 struct curl_slist *list = NULL;
103 for (std::map<std::string, std::string>::const_iterator hdr_iter = req.
headers.begin();
106 if (!strcasecmp(hdr_iter->first.c_str(),
"copy-header")) {
107 list = curl_slist_append(list, hdr_iter->second.c_str());
108 m_headers_copy.emplace_back(hdr_iter->second);
111 if (!strncasecmp(hdr_iter->first.c_str(),
"transferheader",14)) {
112 std::stringstream ss;
113 ss << hdr_iter->first.substr(14) <<
": " << hdr_iter->second;
114 list = curl_slist_append(list, ss.str().c_str());
115 m_headers_copy.emplace_back(ss.str());
119 if (m_is_transfer_state && m_push && m_push_length > 0) {
126 list = curl_slist_append(list,
"Expect: 100-continue");
130 curl_easy_setopt(m_curl, CURLOPT_HTTPHEADER, list);
std::map< std::string, std::string > & headers
References XrdHttpExtReq::headers.
The documentation for this class was generated from the following files: