aboutsummaryrefslogtreecommitdiffstats
path: root/src/ajax.js
diff options
context:
space:
mode:
authorChristian Wenz <christian@wenz.org>2020-04-06 21:15:55 +0200
committerGitHub <noreply@github.com>2020-04-06 21:15:55 +0200
commit7fb90a6beaeffe16699800f73746748f6a5cc2de (patch)
tree7236b990a72a361020ced04f24492b0171444dee /src/ajax.js
parent90fed4b453a5becdb7f173d9e3c1492390a1441f (diff)
downloadjquery-7fb90a6beaeffe16699800f73746748f6a5cc2de.tar.gz
jquery-7fb90a6beaeffe16699800f73746748f6a5cc2de.zip
Ajax: Overwrite s.contentType with content-type header value, if any
This fixes the issue of "%20" in POST data being replaced with "+" even for requests with content-type different from "application/x-www-form-urlencoded", e.g. for "application/json". Fixes gh-4119 Closes gh-4650 Co-authored-by: Richard Gibson <richard.gibson@gmail.com> Co-authored-by: Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
Diffstat (limited to 'src/ajax.js')
-rw-r--r--src/ajax.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ajax.js b/src/ajax.js
index 44ec6e83b..0563c924b 100644
--- a/src/ajax.js
+++ b/src/ajax.js
@@ -861,4 +861,13 @@ jQuery.each( [ "get", "post" ], function( _i, method ) {
};
} );
+jQuery.ajaxPrefilter( function( s ) {
+ var i;
+ for ( i in s.headers ) {
+ if ( i.toLowerCase() === "content-type" ) {
+ s.contentType = s.headers[ i ] || "";
+ }
+ }
+} );
+
export default jQuery;