我在 grails 中遇到了 HTTPBuilder 休息客户端的问题。下面的代码:
withHttp(uri: "http://uclassify.com") {
println "fetching comment sentiments for " + comment.content
get(path : '/browse/uClassify/Sentiment/ClassifyText/', query : [readkey: key, text: comment.content, version: '1.01'], requestContentType: ContentType.XML){resp, data ->
println "data:"
println resp.getData()
println "status"
println resp.getStatus()
println "status line"
println resp.getStatusLine()
println "headers"
println resp.getAllHeaders()
println "data again"
println data
println "finished"
}
与 firebug 和 curl 中显示的标头相比,标头返回正确,但是响应的主体始终为空。内容长度 383 表示服务器正在返回数据(与 firebug 中的标头大小相同)。
这是生成的标准输出。
fetching comment sentiments for something
data:
null
status
200
status line
HTTP/1.1 200 OK
headers
[Date: Fri, 26 Oct 2012 14:55:40 GMT, Server: Microsoft-IIS/6.0, X-Powered-By: ASP.NET, X-AspNet-Version: 2.0.50727, Set-Cookie: ASP.NET_SessionId=ipttqq55rini0t555i53zmvd; path=/; HttpOnly, Cache-Control: private, Content-Type: text/xml; charset=utf-8, Content-Length: 383]
data again
finished
fetching comments complete
有什么想法或建议吗?
谢谢