CodeIgniter“内容编码错误” [英] CodeIgniter "content encoding error"

查看:126
本文介绍了CodeIgniter“内容编码错误”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有任何身体有任何想法如何找到泄漏是什么引发了这个内容编码错误与 $ config ['compress_output'] = true 在CodeIgniter?

Does any body has any idea how to find where the leak is that provokes this "Content Encoding Error" with $config['compress_output'] = true in CodeIgniter?

我试图调试这个错误几天,但我似乎找不到泄漏的地方。 LogLevel 位于 debug ,但是当这个错误发生时,日志中没有信息。

I've trying to debug this error for days, but I can't seem to find where the leak is. LogLevel is at debug but I see no info in the log when this error happens.

所以,任何想法如何调试?

So, any ideas how to debug this?

我真的不想禁用 compress_output 功能,我只想看看如何跟踪错误产生的位置

I really don't want to disable the compress_output feature, I just want to see how can I trace where the error is produced

我一遍又一遍地看了看控制器中是否有任何输出,没有,所以有一些必须在发生错误。没有模型/数据库,只是控制器,库,助手和视图

I've looked over and over again to see if there is any output in the controllers... and there is none, so some where else must be the error provoked. No models/database, just controllers, libraries, helpers and views

推荐答案

此问题是输出缓冲开始的地方。配置变量的检查在 _display()中的 system / core / Output.php 中。在许多代码已经运行之后,它启动了gzip压缩缓冲。这使得在缓冲开始之前已经发生输出的可能性。

This issue is where the output buffering starts. The check for the config variable is in system/core/Output.php in _display(). It starts the gzipped buffering after a lot of code has already run. This leaves the potential for output to have occurred before it buffering starts.

compress_output 设置为 false 没关系,因为没有编码。当它设置为 true 时,最终会出现混合内容。一些输出被编码,一些输出不是导致压缩错误的。

With compress_output set to false it doesn't matter because nothing is encoded. With it set to true you end up with mixed content. Some output is encoded and some is not which causes the compression error.

有两种解决方案:

1 )您可以将 compress_output 设置为false,并将 ob_start('ob_gzhandler'); 添加到索引的顶部。 php文件。这将确保所有输出总是gzip压缩,包括错误。

1) You could leave compress_output set to false and add ob_start('ob_gzhandler'); to the top of your index.php file. This will ensure that all output is always gzipped, including errors.

2)另一个解决方案是添加 ob_flush(); before ob_start('ob_gzhandler'); system / Output.php 中。当没有错误时,这将gzip输出,并在有错误时为您提供未编码的内容。

2) The other solution is to add ob_flush(); before ob_start('ob_gzhandler'); in system/Output.php. This will gzip output when there are no errors and serve you unencoded content when there are errors.

我认为2是更好的解决方案,应该由CodeIgniter团队实施。但是如果您不希望使用系统代码(升级时更改将会消失),那么1是更好的解决方案。

I think 2 is the better solution and should be implemented by the CodeIgniter team. But if you don't want to muck with the system code (changes will go away when you upgrade) then 1 is the better solution for you.

这篇关于CodeIgniter“内容编码错误”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆