title: NSURLConnection different result when get error
body: <p>I'm using <code>-[NSURLConnection initWithRequest...]</code> to connect to a server, 
  and when the server side fails it will respond with an error 400 with a message in the body.
  When there is no error, I can get response data in didReceiveData. But when the server returns an error 400, I do not receive any error message in didReceiveData.</p>
  
  <p>However if I use <code>-[NSURLConnection sendSynchronousRequest...]</code> to do the same request 
  I do get error data from <code>sendSynchronousRequest</code>'s return value.</p>
  
  <p>I want to get the error message from didReceiveData, but I dont know why I cannot get it.
  What is different between the do, can someone help me?</p>
  
  <p>This way I can get the error message:</p>
  
  <pre><code>NSURL *url = [NSURL URLWithString:@"http://devapi.xxx.com/v1/debug/error"];
  NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:url
                                                                cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                            timeoutInterval:240] autorelease];
  
  [request setHTTPMethod:@"POST"];
  
  
  [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
  [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  
  NSURLResponse *response = nil;
  NSError *error = nil;
  NSData *data = [NSURLConnection sendSynchronousRequest:request
                                       returningResponse:&amp;response
                                                   error:&amp;error];
  
  
  NSLog(@"STATUS:%d", [((NSHTTPURLResponse *)response) statusCode]);
  NSLog(@"ERROR:%@", error);
  </code></pre>
  
  <p>This way I cannot get it:</p>
  
  <pre><code>NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://devapi.xxx.com/v1/debug/error"]
                                                               cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                           timeoutInterval:240] autorelease];
  
  [request setHTTPMethod:@"POST"];
  
  
  [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
  [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  urlConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
  
  - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
      NSLog(@"statusCode:%d",((NSHTTPURLResponse *)response).statusCode);
  }
  
  - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
  }
  - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
  [receivedData appendData:data];
  NSLog(@"DATA:%@",[NSString stringWithCString:[receivedData bytes] encoding:NSASCIIStringEncoding]);
  }
  </code></pre>