Uploaded image for project: 'AeroGear'
  1. AeroGear
  2. AEROGEAR-5170

local http object cancel task

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Done
    • Major
    • None
    • None
    • None
    • None

    Description

      when using following snippet (as advice in readme):
      let http = Http(baseURL: "http://server.com")
      http.GET("/get", completionHandler: {(response, error) in
      // handle response
      })
      http.POST("/post", parameters: ["key": "value"], completionHandler: {(response, error) in
      // handle response
      })

      in one method called, task get cancelled. This is due to the deinit call:
      https://github.com/aerogear/aerogear-ios-http/blob/master/AeroGearHttp%2FHttp.swift#L105
      which occurs when http get released.
      As advice in apple doc, releasing NSURLSession is important to prevent memory leak.
      But in our case, we doing this releasing at the wrong place/moment.

      workaround solution: only use http as instance variable of your ViewController

      Possible ways forward:

      • use singleton instance and make sure instance is not released until last callback is called, a la Alamofire
      • remove deinit?

      Attachments

        Activity

          People

            Unassigned Unassigned
            corinnekrych_jira Corinne Krych (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: