title: NSURLSession, upload task - Get actual bytes transferred
body: <p>I was getting bug reports that my iOS app failed upload of images on slow connections. While my timeout probably wasn't high enough, there was another issue. </p>
  
  <p>I found that upload progress quickly went to 100% even though I could see in Charles that bytes were still being transferred. I use the following method of NSURLSession:</p>
  
  <pre><code>- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
                                       fromData:(NSData *)bodyData
                              completionHandler:(void (^)(NSData *data,
                                                          NSURLResponse *response,
                                                          NSError *error))completionHandler
  </code></pre>
  
  <p>and implement the following delegate method to receive progress events:</p>
  
  <pre><code>- (void)URLSession:(NSURLSession *)session
                task:(NSURLSessionTask *)task
     didSendBodyData:(int64_t)bytesSent
      totalBytesSent:(int64_t)totalBytesSent
  totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend
  </code></pre>
  
  <p>Actually I'm using AFNetworking 2.5.2, which uses this method. My theory is that this delegate method reports on bytes sent from the phone and NOT actual bytes transferred.</p>
  
  <p>Sending 300kb at a very low connection will send 5-6 packages immediately and report a progress of 100% while waiting for them to be received.</p>
  
  <p>Is it possible to get progress events on the actual number of bytes that have been confirmed transferred?</p>