feedhenry / fh-ios-swift-sdk

FeedHenry iOS (Swift) SDK
http://feedhenry.org
4 stars 17 forks source link

headers for cloud requests are not sent #20

Closed ezeeFlop closed 6 years ago

ezeeFlop commented 8 years ago

the headers parameters used in the FH.cloud(path, method: method,args: params,headers: headers,completionHandler:) are not sent to the final request executed by the CloudRequest class; I suggest the modifications here below in the CloudRequest class:

 public func exec(completionHandler: CompletionBlock) -> Void {
        let host = props.cloudHost
        if (self.headers == nil) {
            headers = [:]
        }
        if let sessionToken = dataManager.stringForKey("sessionToken") {
            headers = ["x-fh-sessionToken": sessionToken]
        }
        if let props = config?.params {
            headers = headers ?? [:]
            for (key, value) in props {
                let fhKey = "x-fh-\(key)"
                if let value = value as? String {
                    headers![fhKey] = value
                } else { // apppend JSOnified version
                    do {
                        let json = try NSJSONSerialization.dataWithJSONObject(value, options: NSJSONWritingOptions())
                        let string = NSString(data: json, encoding: NSUTF8StringEncoding)
                        headers![fhKey] = string as! String
                    } catch _ {}
                }
            }
        }
        request(method, host: host, path: path, args: args, headers: headers, completionHandler: completionHandler)
    }
danielpassos commented 6 years ago

Hey @ezeeFlop I have created a issues on Jira to fix it.

See: https://issues.jboss.org/browse/FH-4318