Bug Tracker

Modify

Ticket #6674 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

GET request sends Content-Type header when data on URI

Reported by: harbulot Owned by:
Priority: undecided Milestone: 1.4.3
Component: ajax Version: 1.4.2
Keywords: Cc:
Blocking: Blocked by:

Description

Hello,

The fix for ticket #4183 (between 1.3.2 and 1.4) implies that GET and HEAD ajax requests send a 'Content-Type' header when they should not, since these methods do not have a message-body. Some servers refuse GET requests with a Content-Type header.

The problem is around line 352 in src/ajax.js:

if ( s.data || origSettings && origSettings.contentType ) {
        xhr.setRequestHeader("Content-Type", s.contentType);
}

A fix could be:

if ( (s.data && type !== "GET" && type != "HEAD") || origSettings && origSettings.contentType ) {
        xhr.setRequestHeader("Content-Type", s.contentType);
}

Best wishes,

Bruno.

Change History

comment:1 Changed 3 years ago by harbulot

I forgot to say that, if I specify "contentType": null explicitly as a parameter to $.ajax, Firefox does not send the Content-Type header, but Opera does (Content-Type: null, so the problem remains.

comment:2 Changed 3 years ago by dmethvin

See also #6811.

comment:3 Changed 3 years ago by john

  • Priority set to undecided
  • Status changed from new to closed
  • Resolution set to fixed

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.