2014-12-26 10 views
1

我很明顯在這裏錯過了一些東西。我使用:如何訪問HttpResponse中的文本字符串?

let response = Http.Request("http://something.com/api/blahblah") 

檢索一個HttpResponse,但如何獲得對sgtring在體內返回。例如,如果我想要做這樣的事情:

let info = response.Body.Text 

我知道我可以通過使用Http.RequestString直接得到字符串,但有沒有辦法使用Http.Request還怎麼做呢?

回答

4

這裏是HTTP Utilities頁樣本:

let logoUrl = "https://raw.github.com/fsharp/FSharp.Data/master/misc/logo.png" 
match Http.Request(logoUrl).Body with 
| Text text -> 
    printfn "Got text content: %s" text 
| Binary bytes -> 
    printfn "Got %d bytes of binary content" bytes.Length 

是不是你需要什麼?