Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6617031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:39:19+00:00 2026-05-25T20:39:19+00:00

I have been developing an iPad application which downloads some PDF files using ASIHTTPRequest.

  • 0

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];

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).

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);

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.

  • Opening the URL for the “good server”, the status bar shows “completed 1.4 of 20.3 MB”.
  • Open the URL for the “bad server”, the status bar shows “completed 1.4 MB of ?”.

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

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?

Thanks!

Update 5/18/11

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:

Good Server

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

Bad Server

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

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.

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

Thanks!

Final Update: Resolved

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

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

Thanks so much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:39:20+00:00Added an answer on May 25, 2026 at 8:39 pm

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

    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

    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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing an iPad application in which I want to implement multithreading,
I have been developing Android application, and I need to read PDF-files in my
I'm developing an iPad application. I have been provided with a PNG image that
I have been developing a Silverlight application using WCF. The problem is that sometimes
I have been developing an application for the last 12 months using VS2008, VB.NET(WPF)
I have an iPad application that I have been developing on simulator just fine
I have been developing an Android application and testing the orientation sensor using SensorSimulator
I have been using jquery mobile for developing a restaurant e-menu for ipad and
I have been developing a C# windows form application in XP. It all works
I have been developing with objective C and the Cocoa framework for quite some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.