无法显示来自新服务器文件的下载进度(工作previous服务器上) [英] Unable to show Download Progress of File from New Server (worked on previous server)

查看:93
本文介绍了无法显示来自新服务器文件的下载进度(工作previous服务器上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发一个iPad应用程序,它会下载使用ASIHTT prequest一些PDF文件。我一直在使用的进度委托显示出该文件的下载进度用户一个进度条。这里的ASIHTT prequest设置code。

I have been developing an iPad application which downloads some PDF files using ASIHTTPRequest. I have been using the progress delegate to display a progress bar for the user showing the file's download progress. Here's the ASIHTTPRequest setup code.

request = [ASIHTTPRequest requestWithURL:url];
[request setShouldContinueWhenAppEntersBackground:YES];
[request setDownloadDestinationPath:issue.pdfFilepath];     
[request setDownloadProgressDelegate:vc.progressView];
request.showAccurateProgress = YES;
[request setDelegate:self];
[request startAsynchronous];

本已全部奇妙的工作从我的开发服务器读取(好服务器)。然而,现在是时候该应用程序的服务器端移动到我的客户的服务器(坏服务器)。我搬到了一切和我仍然能够成功下载PDF,但进度条不更新,直到下载完成(在整个下载反对)。

This has all been working wonderfully reading from my development server ("good server"). However, it's time to move the server-side of this application to my client's server ("bad server"). I moved everything over and am still able to download the PDF successfully, but the progress bar does not update until the download is complete (as opposed to throughout the download).

这是我一直在使用输出PDF的PHP:(请注意,我也递增观看次数,等基于请求的URL我的数据库,所以我不能简单地从应用程序直接访问PDF。我需要输出从PHP脚本的PDF)。

Here's the PHP I have been using to output the PDF: (Please note that I am also incrementing a view-count, etc in my database based on the requested URL, so I cannot simply access the PDF directly from the app. I need to output the PDF from a PHP script.)

header('Content-type: application/pdf');
header('Content-Disposition:inline filename="downloaded.pdf"');
header('Content-Length: '.remote_filesize($pdfUrl) );
readfile($pdfUrl);

我已经能够确定应用程序没有更新进度条,因为应用程序不知道PDF的总规模开始。我已经在Safari中打开这两个文件来确定这一点。

I have been able to determine that the app is not updating the progress bar because the app does not know the PDF's total size initially. I have determined this by opening both files in Safari.


  • 打开的URL好服务器时,状态栏显示已完成20.3 MB 1.4。

  • 打开的坏服务器的URL,状态栏显示已完成1.4 MB的?。

我已经检查了,我remote_filesize()函数返回21331445(约20 MB)在两台服务器上。

I have checked, and my remote_filesize() function returns 21331445 (approx 20 MB) on both servers.

所以,我在这一点上的结论是,由于某种原因,坏服务器未正确设置,即使我已指定它Content-Length头。有没有可能是preventing这个php.ini文件中的任何设置?任何人都可以提供如何解决或解决此进一步的任何其他建议?

So, my conclusion at this point is that for some reason, the "bad server" is not correctly setting the Content-Length header even though I have specified it. Is there any setting in the php.ini file which might be preventing this? Can anyone offer any other suggestions of how to resolve or troubleshoot this further?

谢谢!

更新11-5-18

由于AJ的在Firefox检查头很好的建议,我发现,坏的服务器的使用gzip COM pression,并没有设定我Conent长度。这里的比较:

Thanks to AJ's excellent suggestion of inspecting the headers in Firefox, I found that the "bad server" is using gzip compression, and not setting my Conent-Length. Here's the comparison:

良好的服务器

Server: Apache
X-Powered-By: PHP/5.3.3
Content-Disposition: inline filename="downloaded.pdf"
Content-Length: 21331445
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: application/pdf
200 OK

坏服务器

Server: Apache
X-Powered-By: PHP/5.2.17
Content-Disposition: inline filename="downloaded.pdf"
Vary: Accept-Encoding
Content-Encoding: gzip
Keep-Alive: timeout=10, max=30
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/pdf
200 OK

我发现了一些文章建议通过确保output_buffering =关和zlib.output_com pression =关在php.ini文件中把gzip的关闭。这样的话,虽然,我的phpinfo()从两个服务器显示,output_buffering和output_com pression被关闭。

I found some articles suggesting to turn gzip off by making sure that "output_buffering = Off" and "zlib.output_compression = Off" in the php.ini file. This is the case though, and my phpinfo() from both servers shows that output_buffering and output_compression are turned off.

我们肯定是在正确的轨道上。从这里为什么这有什么建议被gzip压缩?而如何prevent呢?

We're certainly on the right track. Any suggestions from here on why this is being gzipped? And how to prevent it?

谢谢!

最后更新:解决

我发现了托管服务提供商的网站上的论坛,有人解释说,gzip的最近被打开,并详细介绍了如何阻止它。 http://www.bluehostforum.com/showthread.php?18996-Turning -off-Gzip已

I found a forum on the hosting provider's website where someone explained that gzip has recently been turned on, and detailed how to stop it. http://www.bluehostforum.com/showthread.php?18996-Turning-off-Gzip

基本上,我增加了以下到我的.htaccess文件,即关闭了gzip的COM pression。然后,我得到的Content-Length头,和我的进度条。

Basically, I added the following to my .htaccess file, which turns off the gzip compression. Then, I get the Content-Length header, and my progress bar.

SetEnv no-gzip dont-vary

太感谢了!

推荐答案

刚刚发布的结果作为一个答案,从而回答我可以标记的问题。感谢所有的有用的意见!

Just posting the result as an answer so I can mark the question as answered. Thanks to all for the helpful comments!

我发现了托管服务提供商的网站上的论坛,有人解释说,gzip的最近被打开,并详细介绍了如何阻止它。 http://www.bluehostforum.com/showthread.php?18996-Turning -off-Gzip已

I found a forum on the hosting provider's website where someone explained that gzip has recently been turned on, and detailed how to stop it. http://www.bluehostforum.com/showthread.php?18996-Turning-off-Gzip

基本上,我增加了以下到我的.htaccess文件,即关闭了gzip的COM pression。然后,我得到的Content-Length头,和我的进度条。

Basically, I added the following to my .htaccess file, which turns off the gzip compression. Then, I get the Content-Length header, and my progress bar.

SetEnv no-gzip dont-vary

这篇关于无法显示来自新服务器文件的下载进度(工作previous服务器上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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