ajax post - I want to change the Accept-Encoding header value

后端 未结 3 2077
醉梦人生
醉梦人生 2021-02-04 11:38

I am using jQuery ajax to call my WCF service with an HTTP POST. The response is GZIP encoded, and this causes problems in my environment. (See this question). If the response i

3条回答
  •  忘掉有多难
    2021-02-04 11:48

    This is not possible because of choosing the right encoding type by browser. If you do this

    var ajaxParams = {
    accepts: 'text/html',
    async: true,
    cache: false,
    contentType: 'text/html',
    url: 'http://www.google.com',
    type: 'GET',
    beforeSend: function (jqXHR) {
        // set request headers here rather than in the ajax 'headers' object
        jqXHR.setRequestHeader('Accept-Encoding', 'deflate');
    },......
    

    You'll see this error:

    Refused to set unsafe header "Accept-Encoding"
    

    Ref: App Engine Accept-Encoding

提交回复
热议问题