Feature #50509

Switch to jsonbody if AJAX-Call exceeds length limit

Added by Stefan Froemken over 7 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Should have
Category:
Backend API
Target version:
-
Start date:
2013-07-29
Due date:
% Done:

100%

Estimated time:
PHP Version:
5.3
Tags:
Complexity:
easy
Sprint Focus:

Description

Hello Core-Team,

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:

https://www.ruby-forum.com/topic/94728
http://www.sencha.com/forum/archive/index.php/t-4352.html
http://stackoverflow.com/questions/1097651/is-there-a-practical-http-header-length-limit

For now I have change contentType from "json" to "jsonbody" and my table works again on live system:

$ref->setContentFormat('jsonbody');

In my kind of view you should deactive putting data into the header.

Stefan

#1

Updated by Gerrit Code Review over 7 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22655

#2

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.

#3

Updated by Philipp Gampe over 7 years ago

  • Subject changed from Error 500 while AJAX-Call in BE to Switch to jsonbody if AJAX-Call exceeds length limit
#4

Updated by Stefan Froemken over 7 years ago

Hello Philipp,

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.

#5

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.

#6

Updated by Gerrit Code Review over 6 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/22655

#7

Updated by Gerrit Code Review over 6 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/22655

#8

Updated by Gerrit Code Review over 6 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/22655

#9

Updated by Gerrit Code Review about 6 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/22655

#10

Updated by Benni Mack about 6 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#11

Updated by Wouter Wolters almost 5 years ago

  • Target version deleted (6.2.0)
#12

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.

#13

Updated by Benni Mack over 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF