void get_kernel_buildid (void);
long get_response_code (void);
static int trace (CURL *, curl_infotype type, unsigned char *data, size_t size, void *);
+ bool delete_op (const std::string & url);
private:
size_t get_header (void *ptr, size_t size, size_t nitems);
}
+// Ask the server to delete a URL.
+
+bool
+http_client::delete_op (const std::string & url)
+{
+ if (curl)
+ curl_easy_reset (curl);
+ curl = curl_easy_init ();
+ curl_global_init (CURL_GLOBAL_ALL);
+ if (s.verbose > 2)
+ {
+ curl_easy_setopt (curl, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt (curl, CURLOPT_DEBUGFUNCTION, trace);
+ }
+ curl_easy_setopt (curl, CURLOPT_URL, url.c_str ());
+ curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1); //Prevent "longjmp causes uninitialized stack frame" bug
+ curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
+
+ CURLcode res = curl_easy_perform (curl);
+ if (res != CURLE_OK)
+ {
+ clog << "curl_easy_perform() failed: " << curl_easy_strerror (res)
+ << endl;
+ return false;
+ }
+ return true;
+}
+
+
http_client_backend::http_client_backend (systemtap_session &s)
: client_backend(s), files_seen(false)
{
clog << "Couldn't find 'stdout' in JSON results data" << endl;
return 1;
}
+
+ // Tell the server to delete this build (and any associated result).
+ http->delete_op (build_uri);
return 0;
}
individual_build_rh(string n) : request_handler(n) {}
response GET(const request &req);
+ response DELETE(const request &req);
};
response individual_build_rh::GET(const request &req)
return rsp;
}
+response individual_build_rh::DELETE(const request &req)
+{
+ // matches[0] is the entire string '/builds/XXXX'. matches[1] is
+ // just the buildid 'XXXX'.
+ string buildid = req.matches[1];
+ build_info *b = NULL;
+ {
+ // Use a lock_guard to ensure the mutex gets released even if an
+ // exception is thrown.
+ lock_guard<mutex> lock(builds_mutex);
+ for (auto it = build_infos.begin(); it != build_infos.end(); it++) {
+ if (buildid == (*it)->get_uuid_str()) {
+ b = *it;
+ build_infos.erase(it);
+ break;
+ }
+ }
+ }
+
+ if (b == NULL) {
+ server_error(_F("Couldn't find build '%s'", buildid.c_str()));
+ return get_404_response();
+ }
+
+ // At this point we've found a matching build. Delete it.
+ delete b;
+ response rsp(300);
+ rsp.content = "";
+ return rsp;
+}
+
class individual_result_rh : public request_handler
{
public: