Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/HTTPCommands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,15 @@ bool HTTPRequest::SetupHandle(CURL *curl) {
}
}

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

if (httpVerb == "POST") {
rv = curl_easy_setopt(curl, CURLOPT_POST, 1);
if (rv != CURLE_OK) {
Expand Down Expand Up @@ -827,3 +836,13 @@ bool HTTPHead::SendRequest() {
}

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

HTTPMkcol::~HTTPMkcol() {}

bool HTTPMkcol::SendRequest() {
httpVerb = "MKCOL";
expectedResponseCode = 201;
std::string noPayloadAllowed;
return SendHTTPRequest(noPayloadAllowed);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change

16 changes: 16 additions & 0 deletions src/HTTPCommands.hh
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,19 @@ class HTTPHead : public HTTPRequest {
protected:
std::string object;
};

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

virtual ~HTTPMkcol();

virtual bool SendRequest();

protected:
std::string object;
};
8 changes: 8 additions & 0 deletions src/HTTPFileSystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "HTTPFileSystem.hh"
#include "HTTPDirectory.hh"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
#include "HTTPDirectory.hh"

#include "HTTPCommands.hh"
#include "HTTPFile.hh"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
#include "HTTPFile.hh"
#include "HTTPDirectory.hh"
#include "HTTPFile.hh"

#include "logging.hh"

Expand Down Expand Up @@ -173,3 +174,10 @@ int HTTPFileSystem::Create(const char *tid, const char *path, mode_t mode,

return 0;
}

int HTTPFileSystem::Mkdir(const char *path, mode_t mode, int mkpath,
XrdOucEnv *env) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint] reported by reviewdog 🐶

Suggested change
XrdOucEnv *env) {
XrdOucEnv *env) {

HTTPMkcol mkcol(m_url_base, path, m_log, getToken());
mkcol.SendRequest();
return 0;
}
4 changes: 1 addition & 3 deletions src/HTTPFileSystem.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ class HTTPFileSystem : public XrdOss {
int Init(XrdSysLogger *lp, const char *cfn) { return 0; }
int Init(XrdSysLogger *lp, const char *cfn, XrdOucEnv *en) { return 0; }
int Mkdir(const char *path, mode_t mode, int mkpath = 0,
XrdOucEnv *env = 0) {
return -ENOSYS;
}
XrdOucEnv *env = 0);
int Reloc(const char *tident, const char *path, const char *cgName,
const char *anchor = 0) {
return -ENOSYS;
Expand Down
9 changes: 9 additions & 0 deletions test/http_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ TEST(TestHTTPFile, TestXfer) {
ASSERT_EQ(fh->Close(), 0);
}

TEST(TestHTTPFile, TestMkdir) {
XrdSysLogger log;

HTTPFileSystem fs(&log, g_config_file.c_str(), nullptr);

const auto ret = fs.Mkdir("newdir/", 0755);
ASSERT_EQ(ret, 0);
}

class TestHTTPRequest : public HTTPRequest {
public:
XrdSysLogger log{};
Expand Down
2 changes: 1 addition & 1 deletion test/xrdhttp-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ EOF

cat > $XROOTD_CONFIGDIR/authdb <<EOF

u * / lr
u * / lri

EOF

Expand Down
Loading