title: URLSession dataTask method returns 0 bytes of data
body: <p>I am using URLSession's dataTask method with a completion handler. The error in response is nil, but the data object returns something, it returns 0 bytes of data.</p>
  
  <p>I was using Alamofire library firstly, I thought there is something wrong with it because I started using newer version so I stated using my own implementation of Alamofire just so I don't have to rewrite all the calls I already have in my app.</p>
  
  <p>It still returns 0 bytes of data.</p>
  
  <p>When I use the same URL in the Playground with a simple URLSession call, it works and returns the data, do you have any idea what might go wrong?</p>
  
  <p>My implementation of Alamofire (Srsly quick and dirty within 30 minutes):</p>
  
  <pre><code>import Foundation
  
  typealias DataResponse = (data: Data?, response: URLResponse?, error: Error?, request: URLRequest?, result: Result)
  
  public class Alamofire: NSObject {
  
      enum Method: String {
          case get = "GET"
          case post = "POST"
      }
  
      fileprivate static let session = URLSession(configuration: URLSessionConfiguration.default)
  
      public struct request {
          var request: URLRequest? = nil
          var url: URL? = nil
          let method: Alamofire.Method?
          let parameters: Parameters?
          let headers: Headers?
  
          init(_ request: URLRequest, method: Alamofire.Method? = nil, parameters: Parameters? = nil, headers: Headers? = nil) {
              self.request = request
              self.url = request.url
              self.method = method
              self.parameters = parameters
              self.headers = headers
          }
  
          init(_ url: URL, method: Alamofire.Method? = nil, parameters: Parameters? = nil, headers: Headers? = nil) {
              self.url = url
              self.request = URLRequest(url: url)
              self.method = method
              self.parameters = parameters
              self.headers = headers
          }
      }
  }
  
  typealias Parameters = [String: Any?]
  typealias Headers = [String: String]
  
  extension Alamofire.request {
  
      func responseData(completionHandler: @escaping (_ dataResponse: DataResponse) -&gt; Void) {
          guard let request = request else { return }
  
          Alamofire.session.dataTask(with: request) { (data, response, error) in
              let result: Result
              if let error = error {
                  result = Result.failure(error)
                  completionHandler((data, response, error, request, result))
                  return
              }
  
              completionHandler((data, response, error, request, Result.success))
          }.resume()
      }   
  }
  
  enum Result {
      case success
      case failure(Error)
  }
  </code></pre>