Closed Bug 1334877 Opened 3 years ago Closed 2 years ago
Firefox ajax Content type not well format and is an error in spring
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0 Build ID: 20170125094131 Steps to reproduce: today is 2017-1-29 I'am develop my web site with spring mvc restful http. Yestday, all thing is well. today I change nothing with my code, but update firefox with 51.0.1, and then post the ajax json request (Use HttpRequester plugin to mock) The HttpRequester was not updated since 2016-04-30 Actual results: It show me http 415 error. I debug with my code with spring(4.3.6.RELEASE). the code I found in the class : org.springframework.http.HttpHeaders,method is getContentType() at line 744. -->the mediaType value it get from content type is: "application/json, application/json" and then got a http error 415 (Yestoday before firefox udpated, it works,but now it don't) Expected results: -->the right content type should be : "application/json; utf-8" I change use other browser to mock request is all well. SpringMVC spilit the content type with ";", so did other browser. I think it is a bug in new version of firefox
Severity: normal → major
Component: Untriaged → Networking: HTTP
OS: Unspecified → Windows 7
Priority: -- → P3
Hardware: Unspecified → x86_64
Could you attach a minimized test case?
(In reply to Masatoshi Kimura [:emk] from comment #4) > Could you attach a minimized test case? Maybe I could. var x = new XMLHttpRequest(); x.open('GET', 'mimetype.cgi', false); x.setRequestHeader('Content-Type', 'application/json'); x.setRequestHeader('Content-Type', 'application/json'); x.send(); Use developer tools to see the request header. Regression range: https://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=ecee67ed1ddf9169f89980b97f123566897fcef4&tochange=4a87074952ee8382ac78111c9d86c6fcf1d5f7d4 But... Other browsers (at least Chrome/IE/Edge) also set Content-Type to "application/json, application/json" with this testcase. Is spring mvc doing some stupid User-Agent sniffing?
>Is spring mvc doing some stupid User-Agent sniffing? It's tough to tell. My changes were made to bring Firefox in line with the spec text and tests, so maybe there is something I (or the text/tests) missed. However, based on what I'm reading here it does seem suspect that they would expect a ";charset=utf8" if they are setting the request content type manually to "application/json, application/json", and if other browsers are working despite doing the same thing, then it does sound like they were maybe working around Firefox's old behavior, and now it's breaking.
Digging into their code, I don't really see why there is a problem here. getContentType() is defined at https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/HttpHeaders.java#L859 That just calls MediaType.parseMediaType(), https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/MediaType.java#L475 Which in turn calls parseMimeType(), https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java#L176 I don't see any obvious sniffing (or why that's failing based on that code), and the 4.3.x branch seems to be basically the same version as master. I'll try to find the time today to set up a SpringMVC instance and diagnose this further.
(In reply to blackcatIan from comment #1) > Created attachment 8831519 [details] > firefox mock ajax result Ah, the bug resides the client side rather than the server side: https://addons.mozilla.org/ja/firefox/files/browse/286868/file/content/HTTP.js#L137 HttpRequester add-on calls setRequestHeader() twice, so this is an expected behavior since Firefox 51. HttpRequester should fix the bug.
Component: Networking: HTTP → Extension Compatibility
Product: Core → Firefox
Good thinking to check that out. Thanks!
Mass-closing old Extension Compatibility bugs that relate to legacy add-ons or NPAPI plug-ins. If you think this bug is still valid, please reopen or comment. Sorry for the bug spam, and happy Friday!
Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.