Switch to jsonbody if AJAX-Call exceeds length limit
I have programmed an extension on my local machine and everything works like expected. Then I push my extension to live and all AJAX-Calls to ajax.php returns an Error 500. I can activate all debugging informations in Installtool, but there is still this Error. No further informations available. So I started step-by-step debugging in Source.
The error appears at this line:
header('X-JSON: '.($this->contentFormat != 'jsonbody' ? $content : TRUE));
Maybe this part is OK for very small AJAX-Calls. But in my case I retrieve data for a table and I think the size of my JSON is too large for header. I found some information about it here:
For now I have change contentType from "json" to "jsonbody" and my table works again on live system:
In my kind of view you should deactive putting data into the header.
Updated by Philipp Gampe over 7 years ago
- Tracker changed from Bug to Feature
- Assignee set to Stefan Froemken
- TYPO3 Version changed from 4.7 to 6.2
Sending small data via Header saves a few bytes for small requests, thus this should be the default behavior.
Anyway, the core could be smart enough to automatically switch to jsonbody if the Header line exeeds 8190 bytes (see stackoverflow).
I am changing this to a features as I do not think that this is a TYPO3 error. The programmer should know if he sends large data, that he might run into server limits.
Let me know if you disagree.
Updated by Stefan Froemken over 7 years ago
I agree with you, that it may be OK to send small JSON-Strings by Header, but I disagree to make this way the default. The header way is only for small additional descriptions of the content and it can't be that we want to abuse the header way as default.
Updated by Xavier Perseguers over 7 years ago
I'm wondering if this limit of 8190 bytes will always be available. I'm thinking about reverse proxies, ... that may (?) by default be configured with a lower limit. I don't have examples at hand, just a warning from my point of view that in fact relying on misusing header to save some bytes is /maybe/ not wise.
To be confirmed by going through a few of reverse proxy documentation for default settings.
Updated by Thomas Mayer almost 5 years ago
The patch made it into TYPO3 via target version 7.2.0, according to https://github.com/TYPO3/TYPO3.CMS/commit/3124ebb4df25fa3712faa51e1624a2e96c38fe8e
TYPO3 6.2.x remains unfixed according to #76340 -> still defaults to 'jsonhead' for 'json' as of 6.2.25.