This is an automated email from the ASF dual-hosted git repository. wuzhiguo pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push: new 4830adb9bc AMBARI-25175: Start, Stop, Service Check and other request actions using PUT/POST from Ambari UI do not respond when tried via Knox TP (#3467) 4830adb9bc is described below commit 4830adb9bca4640584e82ace1be6c48603df61ff Author: Zhiguo Wu <wuzhi...@apache.org> AuthorDate: Wed Nov 9 16:45:42 2022 +0800 AMBARI-25175: Start, Stop, Service Check and other request actions using PUT/POST from Ambari UI do not respond when tried via Knox TP (#3467) --- .../java/org/apache/ambari/server/api/services/RequestFactory.java | 2 ++ ambari-server/src/test/python/ldap-password.dat | 2 +- ambari-web/app/utils/ajax/ajax.js | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestFactory.java index a26518dec8..dec4990ed6 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestFactory.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestFactory.java @@ -26,6 +26,7 @@ import java.util.Map; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.UriInfo; +import org.apache.ambari.server.api.predicate.QueryLexer; import org.apache.ambari.server.api.resources.ResourceDefinition; import org.apache.ambari.server.api.resources.ResourceInstance; @@ -154,6 +155,7 @@ public class RequestFactory { */ private boolean applyDirectives(Request.Type requestType, RequestBody body, UriInfo uriInfo, ResourceInstance resource) { Map<String, String> queryParameters = getQueryParameters(uriInfo, body); + queryParameters.remove(QueryLexer.QUERY_DOAS); // KNOX appends a doAs parameter to every request. Ignore this as it's neither a query predicate nor a directive. Map<String, String> requestInfoProperties; boolean allDirectivesApplicable = true; if (!queryParameters.isEmpty()) { diff --git a/ambari-server/src/test/python/ldap-password.dat b/ambari-server/src/test/python/ldap-password.dat index 7aa311adf9..c7589bd860 100644 --- a/ambari-server/src/test/python/ldap-password.dat +++ b/ambari-server/src/test/python/ldap-password.dat @@ -1 +1 @@ -password \ No newline at end of file +${alias=ambari.ldap.manager.password} \ No newline at end of file diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js index dd34184fa5..308c07121b 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -3321,6 +3321,10 @@ var formatRequest = function (data) { if (this.format) { jQuery.extend(opt, this.format(data, opt)); } + if (!('headers' in opt && 'Content-Type' in opt.headers)) { + // With the default www-url-form-encoded Content-Type KNOX would corrupt the json content. + opt.headers['Content-Type'] = 'text/plain'; + } var statusCode = jQuery.extend({}, require('data/statusCodes')); statusCode['404'] = function () { console.log("Error code 404: URI not found. -> " + opt.url); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@ambari.apache.org For additional commands, e-mail: commits-h...@ambari.apache.org