This commit is contained in:
Adam D. Ruppe 2019-02-18 15:59:06 -05:00
parent 076d28dba1
commit 15e648f43e
1 changed files with 10 additions and 6 deletions

16
cgi.d
View File

@ -697,7 +697,7 @@ class Cgi {
} }
} else { } else {
// it is an argument of some sort // it is an argument of some sort
if(requestMethod == Cgi.RequestMethod.POST) { if(requestMethod == Cgi.RequestMethod.POST || requestMethod == Cgi.RequestMethod.PATCH || requestMethod == Cgi.RequestMethod.PUT) {
auto parts = breakUp(arg); auto parts = breakUp(arg);
_post[parts[0]] ~= parts[1]; _post[parts[0]] ~= parts[1];
allPostNamesInOrder ~= parts[0]; allPostNamesInOrder ~= parts[0];
@ -906,7 +906,7 @@ class Cgi {
// FIXME: DOCUMENT_ROOT? // FIXME: DOCUMENT_ROOT?
// FIXME: what about PUT? // FIXME: what about PUT?
if(requestMethod == RequestMethod.POST) { if(requestMethod == RequestMethod.POST || requestMethod == Cgi.RequestMethod.PATCH || requestMethod == Cgi.RequestMethod.PUT) {
version(preserveData) // a hack to make forwarding simpler version(preserveData) // a hack to make forwarding simpler
immutable(ubyte)[] data; immutable(ubyte)[] data;
size_t amountReceived = 0; size_t amountReceived = 0;
@ -6499,14 +6499,18 @@ class RestObject(Helper = void) : WebObject!Helper {
return null; return null;
} }
void replace() {} void replace() {
save();
}
void replace(string urlId, scope void delegate() applyChanges) { void replace(string urlId, scope void delegate() applyChanges) {
load(urlId); load(urlId);
applyChanges(); applyChanges();
replace(); replace();
} }
void update(string[] fieldList) {} void update(string[] fieldList) {
save();
}
void update(string urlId, scope void delegate() applyChanges, string[] fieldList) { void update(string urlId, scope void delegate() applyChanges, string[] fieldList) {
load(urlId); load(urlId);
applyChanges(); applyChanges();
@ -6723,7 +6727,7 @@ auto serveRestObject(T)(string urlPrefix) {
if(url.length && url[$ - 1] == '/') { if(url.length && url[$ - 1] == '/') {
// remove the final slash... // remove the final slash...
cgi.setResponseLocation(cgi.pathInfo[0 .. $ - 1]); cgi.setResponseLocation(cgi.scriptName ~ cgi.pathInfo[0 .. $ - 1]);
return true; return true;
} }
@ -6949,7 +6953,7 @@ bool restObjectServeHandler(T)(Cgi cgi, string url) {
string n = obj.create(&applyChanges); string n = obj.create(&applyChanges);
} }
auto newUrl = cgi.pathInfo ~ "/" ~ n; auto newUrl = cgi.scriptName ~ cgi.pathInfo ~ "/" ~ n;
cgi.setResponseLocation(newUrl); cgi.setResponseLocation(newUrl);
cgi.setResponseStatus("201 Created"); cgi.setResponseStatus("201 Created");
cgi.write(`The object has been created.`); cgi.write(`The object has been created.`);