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 8132729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:24:51+00:00 2026-06-06T09:24:51+00:00

Hello i need to create a progressView when i load data from my webservice.

  • 0

Hello i need to create a progressView when i load data from my webservice.

Actually the expectedContentLength alway return -1.

After look lots of similary problem it looks like my webservice never send the Content-Length:.

Then i check with CURL and here is the result :

< HTTP/1.1 200 OK
< Date: Thu, 21 Jun 2012 10:04:39 GMT
< Server: Apache/2.2.16 (Debian)
< X-Powered-By: PHP/5.3.3-7+squeeze9
< cache-control: no-cache
< Vary: Accept-Encoding
< Content-Type: text/html; charset=UTF-8
< Content-Length: 3239  
< Connection: Keep-Alive
< Set-Cookie: PHPSESSID=u4o4i9dofdgnkfmtnf163635j6; path=/

and here is my code to catch length

long long expectDataSize;
long long currentDataSize;

....

 - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response
{
    NSLog(@"expect content length %lld", [response expectedContentLength]);
    expectDataSize = [response expectedContentLength];
    currentDataSize = 0;
}

Anyone have already see this problem ?

  • 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-06-06T09:24:52+00:00Added an answer on June 6, 2026 at 9:24 am

    Ok i’ve fix it myself here is my real problem and a solution :

    When i ask with Curl i can get the length no problem.

    But when i use NSurlConnection

    NSURLConnection *c = [[NSURLConnection alloc] initWithRequest:req delegate:self];
    

    The response will be compress with “Gzip” (don’t ask me why). And if the response is encode with Gzip it’s impossible to know the length, then “expectedContentLength” return -1.
    And “Content-Length” is absent from [response allHeaderFields].

    If you really want to get the length you can simply force to not use Gzip like this :

    [req setValue:@"" forHTTPHeaderField:@"Accept-Encoding"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create an executable from the next assembly code: .MODEL SMALL .DATA
hello i need to do the following: move a node from jstree to another
Hello I want to create my sites links to dynamically, and for me need
Hello i am new in developing Android applications, I need to create an application
Hello I need to make a chart like this : http://www.xe.com/currencycharts/?from=USD}&to=EUR Should I use
Hello all, I need to create a query for house search, that would match
I need to create a bit of Javascript that can search inputted HTML from
Hello, I have the following sql table + data: CREATE TABLE IF NOT EXISTS
(See Edit 2 below for the solution.) I need to create SDL surfaces from
Hello ! I need to create a report like the attachment shows with Jasper

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.