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

  • SEARCH
  • Home
  • 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 6981023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:06:10+00:00 2026-05-27T18:06:10+00:00

I am downloading file (with apache tomcat 6.0.32). When I make disconnect (shutdown tomcat)

  • 0

I am downloading file (with apache tomcat 6.0.32). When I make disconnect (shutdown tomcat) some times ASHITTPRequest generate error, but sometimes (most of times exactly…ALL TIME EXACTLY! Only if there is no connection at the beginning occurs error) it ends work like all correct.

So there is the question: why this happened and how can I watch if the connection lost properly.

Thanks a lot!

UPDATE:

Try to send request through TCPMon and then stop it (TCPMon) and get the same: ASIHTTPRequest think that the downloading correctly done.

UPDATE:

responseHeaders:

"Content-Disposition" = attachment;
"Content-Length" = 2277888;
"Content-Type" = "application/octet-stream";
Date = "Thu, 28 Apr 2011 12:35:32 GMT";
Server = "Apache-Coyote/1.1";
"Set-Cookie" = "JSESSIONID=98CAE6C0C4275B528D5E0F8651546AFE; Path=/ISED";

responseStatusMessage:

 HTTP/1.1 200 OK

UPDATE:

If disconnect computer by hand (disconnect the cable) and get this:

Sometime ASIHTTPRequest waits till timeout, and next request get connecting error.

Sometime error occurs just in time I disconnect.

Sometime error does not occurs just in time I disconnect: download progress missing and (if make connection again) it file starts download from the beginning.

And if close port ASIHTTPRequest thinks that is successful download done.

I can’t understand this logic…

SOLUTION:

I solve the problem by comparing Content-Length in header and total bytes read:

 NSString *contentLength = [[self.request responseHeaders] valueForKey:@"Content-Length"];
 NSString *downloadedBytesCount = [NSString stringWithFormat:@"%llu",[self.request totalBytesRead]];


        if ([contentLength isEqualToString:downloadedBytesCount] == NO) {
           // error maintain 
        } 

So I can check if I got all data and if not: maintain error.
In other cases (like manually disconnect) ASIHTTPRequest work appropriate way and generates errors by self.

  • 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-27T18:06:11+00:00Added an answer on May 27, 2026 at 6:06 pm

    for checking connection status i am using Reachability library with ASI. i believe Reachability comes with ASI not sure.

    this is not mine code i took from somewhere but it is working flawless.

    #import "Reachability.h"
    
    -(void)viewDidAppear:(BOOL)animated
    {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];
    }
    
    - (void) checkNetworkStatus:(NSNotification *)notice
    {
        NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
        switch (internetStatus)
        {
            case NotReachable:
            {
                NSLog(@"The internet is down.");
                //self.internetActive = NO;
    
                break;
            }
            case ReachableViaWiFi:
            {
                NSLog(@"The internet is working via WIFI.");
                //self.internetActive = YES;
    
                break;
            }
            case ReachableViaWWAN:
            {
               NSLog(@"The internet is working via WWAN.");
               //self.internetActive = YES;
               break;
            }
        }
    }
    

    i have altered the code little bit regarding my needs it returns YES/NO. and you should remove observer at some point.

    - (void)viewDidUnload
    {
        [[NSNotificationCenter defaultCenter] removeObserver:self];
    }
    

    thanks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using apache commons-net for downloading a file from an FTP server. That
I am downloading a file from a website and I have the link. But
I get the following error when downloading excel file in SSL site: Internet Explorer
All i need help in downloading a file through headers its working fine but
Basically, I was doing some testing using apache bench. The file i was testing
brew install couchdb fails with: ==> Downloading http://www.apache.org/dyn/closer.cgi?path=couchdb/1.1.1/apache-couchdb-1.1.1.tar.gz File already downloaded in /Users/fairview/Library/Caches/Homebrew ==>
When downloading a file with HTTPUrlConnection is there a way to check if the
I am downloading a file from the server/database via aspx page. When using the
I am downloading PDF file in my application and want to allow user to
I have thread where downloading xml file a this xml file i want to

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.