Skip to content
This repository has been archived by the owner on Jan 29, 2021. It is now read-only.

Ajax component can't handle responses bigger than 4096 #33

Open
highstrike opened this issue Dec 15, 2014 · 12 comments
Open

Ajax component can't handle responses bigger than 4096 #33

highstrike opened this issue Dec 15, 2014 · 12 comments

Comments

@highstrike
Copy link

If you have a response bigger than 4096 then the request type will be text/html instead of application/json

Tested on CakePHP 2.5.7

@milesj
Copy link
Owner

milesj commented Dec 15, 2014

I doubt this is anything that I am doing, the component is pretty straight forward. I'll look into it.

@highstrike
Copy link
Author

found anything interesting? :)

@milesj
Copy link
Owner

milesj commented Dec 16, 2014

Nope. There's nothing in my code that would cause this. Looked into Cake's RequestHandler and didn't find anything there either. Perhaps it's a server configuration?

@highstrike
Copy link
Author

If I put a header content type application json right in your case json on the last function then it works, but I don't wana do that, did you try it on your server and you could do more than 4096?

@milesj
Copy link
Owner

milesj commented Dec 16, 2014

I have not as I don't use CakePHP anymore and have no applications running it.

The RequestHandler sets the content type, not my component.

https://github.com/milesj/utility/blob/master/Controller/Component/AjaxHandlerComponent.php#L147
https://github.com/cakephp/cakephp/blob/master/lib/Cake/Controller/Component/RequestHandlerComponent.php#L667

You're passing JSON to respond() correct?

I also wonder if it's failing somewhere else in Cake, like the Response class.

https://github.com/cakephp/cakephp/blob/master/lib/Cake/Network/CakeResponse.php#L709

@highstrike
Copy link
Author

I left your line 147 as it is, and im doing header('Content-Type: application/json'); before this line:
https://github.com/milesj/utility/blob/master/Controller/Component/AjaxHandlerComponent.php#L186

Would you be willing to setup a simple cake project and try it out?
Thank you :)

@milesj
Copy link
Owner

milesj commented Dec 16, 2014

When I have time (which won't be anytime soon).

I'd try debugging why RequestHandler/Response isn't setting the content type. Forcing the type through headers is the wrong approach.

@highstrike
Copy link
Author

I know it's the wrong approach but it works.

I've tried debugging the request handler / response but got nowhere, at the end $ctype was application/json and $type was json. Even after all that the header content type in the browser was showing up as text/html... so can't really think of anything else =/

@milesj
Copy link
Owner

milesj commented Dec 16, 2014

I wonder if it's happening further down the chain.

What about setting the content type manually from your action? Instead of the component?

@highstrike
Copy link
Author

haven't tried from controller / action yet... will do when i get to work tomorrow.

@highstrike
Copy link
Author

Haven't had a chance to try it out yet, deadlines at work, last 2 days before holidays, couldn't even touch that specific cake project...

@milesj
Copy link
Owner

milesj commented Dec 18, 2014

Same. I probably won't be able to look at this until after the holidays.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants