Deployd继续返回状态204

时间:2016-01-16 19:15:12

标签: ios swift deployd

我正在开发一个iOS应用程序并使用Deployd作为后端。问题是当我向用户/我发送一个带有sid cookie的GET请求来识别我的会话时,它返回204-没有内容,即使用户已登录。我期待一些数据作为回报。

Xcode控制台输出:

<NSHTTPURLResponse: 0x136ed2e00> { URL: http://xxxxxxxxxxxxxxx:2403/users/me?sid=3f53dd6c10...9fc4a00 } { status code: 204, headers {
"Cache-Control" = "no-cache, no-store, must-revalidate";
Connection = "keep-alive";
Date = "Sat, 16 Jan 2016 18:55:16 GMT";
Expires = 0;
Pragma = "no-cache"; } }

1 个答案:

答案 0 :(得分:1)

所以我发送SID作为参数,这是不正确的。 Deployd需要一个屏障标记&#39;。

Swift代码:

let url = NSURL(string: "http:/xxxxxxxxxxxxxxxx.com:2403/users/me")
            let request = NSMutableURLRequest(URL: url!)
            request.HTTPMethod = "GET"
            request.setValue( "Bearer \(token!)", forHTTPHeaderField: "Authorization")

            NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.currentQueue()!) { response, maybeData, error in
                if let data = maybeData {
                    let contents = NSString(data:data, encoding:NSUTF8StringEncoding)
                    print(contents!, "bitch")
                } else {
                    print(error!.localizedDescription)
                }
            }