return RGWPostObj_ObjStore::init(store, s, dialect_handler);
}
-bool RGWFormPost::is_expired(const std::string& expires)
+bool RGWFormPost::is_non_expired()
{
- string err;
- const utime_t now = ceph_clock_now(g_ceph_context);
- const uint64_t expiration = (uint64_t)strict_strtoll(expires.c_str(),
- 10, &err);
- if (!err.empty()) {
- dout(5) << "failed to parse temp_url_expires: " << err << dendl;
- return true;
+ std::string expires = get_part_str(ctrl_parts, "expires", "0");
+
+ std::string err;
+ const uint64_t expires_timestamp =
+ static_cast<uint64_t>(strict_strtoll(expires.c_str(), 10, &err));
+
+ if (! err.empty()) {
+ dout(5) << "failed to parse FormPost's expires: " << err << dendl;
+ return false;
}
- if (expiration <= (uint64_t)now.sec()) {
- dout(5) << "temp url expired: " << expiration << " <= " << now.sec() << dendl;
- return true;
+ const utime_t now = ceph_clock_now();
+ if (expires_timestamp <= static_cast<uint64_t>(now.sec())) {
+ dout(5) << "FormPost form expired: "
+ << expires_timestamp << " <= " << now.sec() << dendl;
+ return false;
}
- return false;
+ return true;
}
bool RGWFormPost::is_integral()
}
} while (! stream_done);
- std::string expires;
- if (part_str(ctrl_parts, "expires", &expires) && is_expired(expires)) {
+ if (! is_non_expired()) {
err_msg = "FormPost: Form Expired";
return -EACCES;
}
std::string get_current_filename() const override;
bool is_next_file_to_upload() override;
bool is_integral();
- static bool is_expired(const std::string& expires);
+ bool is_non_expired();
parts_collection_t ctrl_parts;
boost::optional<post_form_part> current_data_part;