this technically duplicate thread:
however, code in there doesn't seem work me. see in changelogs dispatch handing has changed subtley, life of me cannot work. think problem me understanding scala , not library problem.
import dispatch._, defaults._ // import com.ning.http.client.response object httpdownloader extends app { val goog: req = host("google.com").secure val res = http(goog.head ok as.response).option() print(res) thread.sleep(5000) }
i'm trying headers website know can check content length, error when compile snippet is
[error] ... download.scala:14: type mismatch; [error] found : dispatch.as.response.type [error] required: com.ning.http.client.response => ? [error] val res = http(goog.head ok as.response).option()
i try import client.response instead import com.ning.http.client.{ response => nonconflictingname }, says "object com.ning.http.client.response not value." have no idea means.
if wanted entire response object , don't care non-ok status codes returning failed future, this:
val res = http(goog.head) res oncomplete{ case success(resp) => val headers = resp.getheaders ... case failure(ex) => //handle fail }
if wated ok
status handling, this:
val res = http(goog.head ok(r => r))
Comments
Post a Comment