使用Alamofire处理来自POST请求的非JSON响应

时间:2016-09-22 15:23:50

标签: ios swift alamofire

我正在使用Alamofire 3并且我正在调用的终点(我不拥有服务器)接受POST请求并返回HTML作为响应。< / p>

我在命令行中使用curl时能够获得HTML响应,但是Alamofire不返回响应正文,而只返回标题。< / p>

这是我的代码:

let headers = [
    "Referer": "SOMEURL"
]

Alamofire.request(.POST, url, headers: headers)
    .validate()
    .response { request, response, data, error in
        // do something with response
    }

response是:

Optional(<NSHTTPURLResponse: 0x7f9ba3759760> { URL: SOMEURL } { status code: 200, headers {
    Connection = "keep-alive";
    "Content-Encoding" = gzip;
    "Content-Type" = "text/html";
    Date = "Thu, 22 Sep 2016 15:19:20 GMT";
    Server = nginx;
    "Transfer-Encoding" = Identity;
    Vary = "Accept-Encoding";
} })

data是:

Optional<NSData>
  - Some : <>

有什么想法吗?

0 个答案:

没有答案