Skip to content
Open
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ add_definitions( -D_FILE_OFFSET_BITS=64 )
# On Linux, we hide all the symbols for the final libraries, exposing only what's needed for the XRootD
# runtime loader. So here we create the object library and will create a separate one for testing with
# the symbols exposed.
add_library(XrdS3Obj OBJECT src/CurlUtil.cc src/S3File.cc src/S3Directory.cc src/S3AccessInfo.cc src/S3FileSystem.cc src/AWSv4-impl.cc src/S3Commands.cc src/HTTPCommands.cc src/TokenFile.cc src/stl_string_utils.cc src/shortfile.cc src/logging.cc)
add_library(XrdS3Obj OBJECT src/CurlUtil.cc src/S3File.cc src/S3Directory.cc src/HTTPDirectory.cc src/S3AccessInfo.cc src/S3FileSystem.cc src/AWSv4-impl.cc src/S3Commands.cc src/HTTPCommands.cc src/TokenFile.cc src/stl_string_utils.cc src/shortfile.cc src/logging.cc)
set_target_properties(XrdS3Obj PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(XrdS3Obj PRIVATE ${XRootD_INCLUDE_DIRS})
target_link_libraries( XrdS3Obj ${XRootD_UTILS_LIBRARIES} ${XRootD_SERVER_LIBRARIES} CURL::libcurl OpenSSL::Crypto tinyxml2::tinyxml2 Threads::Threads std::filesystem std::atomic )

add_library(XrdS3 MODULE "$<TARGET_OBJECTS:XrdS3Obj>")
target_link_libraries(XrdS3 XrdS3Obj)

add_library(XrdHTTPServerObj OBJECT src/CurlUtil.cc src/HTTPFile.cc src/HTTPFileSystem.cc src/HTTPCommands.cc src/TokenFile.cc src/stl_string_utils.cc src/shortfile.cc src/logging.cc)
add_library(XrdHTTPServerObj OBJECT src/CurlUtil.cc src/HTTPFile.cc src/HTTPDirectory.cc src/HTTPFileSystem.cc src/HTTPCommands.cc src/TokenFile.cc src/stl_string_utils.cc src/shortfile.cc src/logging.cc)
set_target_properties(XrdHTTPServerObj PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(XrdHTTPServerObj PRIVATE ${XRootD_INCLUDE_DIRS})
target_link_libraries(XrdHTTPServerObj ${XRootD_UTILS_LIBRARIES} ${XRootD_SERVER_LIBRARIES} CURL::libcurl OpenSSL::Crypto Threads::Threads std::filesystem)
target_link_libraries(XrdHTTPServerObj ${XRootD_UTILS_LIBRARIES} ${XRootD_SERVER_LIBRARIES} CURL::libcurl tinyxml2::tinyxml2 OpenSSL::Crypto Threads::Threads std::filesystem)

add_library(XrdHTTPServer MODULE "$<TARGET_OBJECTS:XrdHTTPServerObj>")
target_link_libraries(XrdHTTPServer XrdHTTPServerObj)
Expand Down
56 changes: 55 additions & 1 deletion src/HTTPCommands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ bool HTTPRequest::SendHTTPRequest(const std::string &payload) {
return false;
}

headers["Content-Type"] = "binary/octet-stream";
if (headers.find("Content-Type") == headers.end())
headers["Content-Type"] = "binary/octet-stream";

return sendPreparedRequest(hostUrl, payload, payload.size(), true);
}
Expand Down Expand Up @@ -468,14 +469,26 @@ bool HTTPRequest::SetupHandle(CURL *curl) {
}
}

if (httpVerb == "PROPFIND") {
rv = curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PROPFIND");
if (rv != CURLE_OK) {
this->errorCode = "E_CURL_LIB";
this->errorMessage =
"curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST) failed.";
return false;
}
}

if (httpVerb == "POST") {
rv = curl_easy_setopt(curl, CURLOPT_POST, 1);
if (rv != CURLE_OK) {
this->errorCode = "E_CURL_LIB";
this->errorMessage = "curl_easy_setopt( CURLOPT_POST ) failed.";
return false;
}
}

if (httpVerb == "POST" || httpVerb == "PROPFIND") {
rv = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, m_payload.data());
if (rv != CURLE_OK) {
this->errorCode = "E_CURL_LIB";
Expand Down Expand Up @@ -817,6 +830,47 @@ bool HTTPDownload::SendRequest(off_t offset, size_t size) {

// ---------------------------------------------------------------------------

HTTPList::~HTTPList() {}

bool HTTPList::SendRequest() {
this->expectedResponseCode = 200;

httpVerb = "GET";
std::string noPayloadAllowed;
return SendHTTPRequest(noPayloadAllowed);
}

// ---------------------------------------------------------------------------

HTTPPropfind::~HTTPPropfind() {}

bool HTTPPropfind::SendRequest() {
httpVerb = "PROPFIND";
headers["Depth"] = "1";
headers["Content-Type"] = "application/xml";

if (!object.empty()) {
if (hostUrl.back() != '/' && object.front() != '/') {
hostUrl += '/';
}
hostUrl += object;
}

std::string payload = "<d:propfind xmlns:d=\"DAV:\">"
" <d:prop>"
" <d:resourcetype/>"
" <d:getcontentlength/>"
" <d:getlastmodified/>"
" </d:prop>"
"</d:propfind>";

expectedResponseCode = 207;

return SendHTTPRequest(payload);
}

// ---------------------------------------------------------------------------

HTTPHead::~HTTPHead() {}

bool HTTPHead::SendRequest() {
Expand Down
29 changes: 29 additions & 0 deletions src/HTTPCommands.hh
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,35 @@ class HTTPDownload : public HTTPRequest {
std::string object;
};

class HTTPList : public HTTPRequest {
public:
HTTPList(const std::string &h, const std::string &o, XrdSysError &log,
const TokenFile *token)
: HTTPRequest(h, log, token), object(o) {
hostUrl = hostUrl + "/" + object;
}

virtual ~HTTPList();

virtual bool SendRequest();

protected:
std::string object;
};

class HTTPPropfind : public HTTPRequest {
public:
HTTPPropfind(const std::string &h, const std::string &o, XrdSysError &log,
const TokenFile *token)
: HTTPRequest(h, log, token), object(o) {}

virtual ~HTTPPropfind();

virtual bool SendRequest();

std::string object;
};

class HTTPHead : public HTTPRequest {
public:
HTTPHead(const std::string &h, const std::string &o, XrdSysError &log,
Expand Down
Loading
Loading