HTTP protocol: enable POST for update/delete
This commit is contained in:
@@ -62,12 +62,27 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
scope: null,
|
||||
|
||||
/**
|
||||
* Property: readWithPOST
|
||||
* APIProperty: readWithPOST
|
||||
* {Boolean} true if read operations are done with POST requests
|
||||
* instead of GET, defaults to false.
|
||||
*/
|
||||
readWithPOST: false,
|
||||
|
||||
/**
|
||||
* APIProperty: updateWithPOST
|
||||
* {Boolean} true if update operations are done with POST requests
|
||||
* defaults to false.
|
||||
*/
|
||||
updateWithPOST: false,
|
||||
|
||||
/**
|
||||
* APIProperty: deleteWithPOST
|
||||
* {Boolean} true if delete operations are done with POST requests
|
||||
* defaults to false.
|
||||
* if true, POST data is set to output of format.write().
|
||||
*/
|
||||
deleteWithPOST: false,
|
||||
|
||||
/**
|
||||
* Property: wildcarded.
|
||||
* {Boolean} If true percent signs are added around values
|
||||
@@ -293,7 +308,8 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
requestType: "update"
|
||||
});
|
||||
|
||||
resp.priv = OpenLayers.Request.PUT({
|
||||
var method = this.updateWithPOST ? "POST" : "PUT";
|
||||
resp.priv = OpenLayers.Request[method]({
|
||||
url: url,
|
||||
callback: this.createCallback(this.handleUpdate, resp, options),
|
||||
headers: options.headers,
|
||||
@@ -344,11 +360,16 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
requestType: "delete"
|
||||
});
|
||||
|
||||
resp.priv = OpenLayers.Request.DELETE({
|
||||
var method = this.deleteWithPOST ? "POST" : "DELETE";
|
||||
var requestOptions = {
|
||||
url: url,
|
||||
callback: this.createCallback(this.handleDelete, resp, options),
|
||||
headers: options.headers
|
||||
});
|
||||
};
|
||||
if (this.deleteWithPOST) {
|
||||
requestOptions.data = this.format.write(feature);
|
||||
}
|
||||
resp.priv = OpenLayers.Request[method](requestOptions);
|
||||
|
||||
return resp;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user