HTTP POST 请求转换为 GET 请求
HTTP POST request gets transformed to GET request
WireCloud 代理究竟是如何工作的?我们使用以下代码通过 WireCloud 代理发出请求:
MashupPlatform.http.makeRequest(url, {
method: 'POST',
forceProxy: true,
onSuccess: function (response) {
success(response);
},
onFailure: function (response) {
error(response);
},
onComplete: function () {
complete();
}
});
浏览器网络分析显示 POST 请求被发送到 https://example.com/cdp/https/rest.example.com/path/to/service
。我们的网络服务被 url 调用,但是记录,它收到一个 GET 请求。
tomcat托管的我们rest服务的访问日志显示:
192.168.60.221 - - [26/May/2016:10:38:31 +0200] "GET /path/to/service HTTP/1.1" 405 1013
192.168.60.221 - - [26/May/2016:10:38:42 +0200] "POST /path/to/service HTTP/1.1" 204 -
第一个调用是用上面列出的 MashupPlatform.http.makeRequest
调用完成的,第二个调用是用 jQuery 完成的,如下所示:
$.ajax({
type: "POST",
url: url,
data: null,
success: success
});
当我们在我们的网络服务中设置 CORS header 时,这工作得很好。
WireClouds 代理无法按预期工作的原因可能是什么?
有很多小部件和运算符使用 MashupPlatform
API 和 WireCloud 的 CORS 代理,我们从未见过它将 POST
请求转换为 GET
请求.无论如何,使用 jQuery 没问题;-)。此外,您还可以使用它来执行对不支持 CORS headers 的服务的请求,方法是使用 buildProxyURL
method。例如:
url = MashupPlatform.http.buildProxyURL('https://api.example.com/api/endpoing');
$.ajax({
method: "POST",
url: url,
data: null,
success: success
});
WireCloud 代理究竟是如何工作的?我们使用以下代码通过 WireCloud 代理发出请求:
MashupPlatform.http.makeRequest(url, {
method: 'POST',
forceProxy: true,
onSuccess: function (response) {
success(response);
},
onFailure: function (response) {
error(response);
},
onComplete: function () {
complete();
}
});
浏览器网络分析显示 POST 请求被发送到 https://example.com/cdp/https/rest.example.com/path/to/service
。我们的网络服务被 url 调用,但是记录,它收到一个 GET 请求。
tomcat托管的我们rest服务的访问日志显示:
192.168.60.221 - - [26/May/2016:10:38:31 +0200] "GET /path/to/service HTTP/1.1" 405 1013
192.168.60.221 - - [26/May/2016:10:38:42 +0200] "POST /path/to/service HTTP/1.1" 204 -
第一个调用是用上面列出的 MashupPlatform.http.makeRequest
调用完成的,第二个调用是用 jQuery 完成的,如下所示:
$.ajax({
type: "POST",
url: url,
data: null,
success: success
});
当我们在我们的网络服务中设置 CORS header 时,这工作得很好。
WireClouds 代理无法按预期工作的原因可能是什么?
有很多小部件和运算符使用 MashupPlatform
API 和 WireCloud 的 CORS 代理,我们从未见过它将 POST
请求转换为 GET
请求.无论如何,使用 jQuery 没问题;-)。此外,您还可以使用它来执行对不支持 CORS headers 的服务的请求,方法是使用 buildProxyURL
method。例如:
url = MashupPlatform.http.buildProxyURL('https://api.example.com/api/endpoing');
$.ajax({
method: "POST",
url: url,
data: null,
success: success
});