From 64e471db930ba10c3ac26f4037f57b054f6b197a Mon Sep 17 00:00:00 2001 From: Grant Crofton Date: Thu, 30 Oct 2014 13:12:03 +0000 Subject: [PATCH] Added 1.4.0 notes --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a0dbd47..106ee9a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A gloriously functional HTTP client library for F#! -[![Build status](https://ci.appveyor.com/api/projects/status/vcqrxl5d03xxyoa3/branch/master)](https://ci.appveyor.com/project/GrantCrofton/http-fs/branch/master) [![NuGet](http://img.shields.io/badge/NuGet-1.3.1-blue.svg?style=flat)](http://www.nuget.org/packages/Http.fs/) +[![Build status](https://ci.appveyor.com/api/projects/status/vcqrxl5d03xxyoa3/branch/master)](https://ci.appveyor.com/project/GrantCrofton/http-fs/branch/master) [![NuGet](http://img.shields.io/badge/NuGet-1.4.0-blue.svg?style=flat)](http://www.nuget.org/packages/Http.fs/) ## How do I use it? ## @@ -81,6 +81,20 @@ So you can do the old download-multiple-sites-in-parallel thing: |> Array.iter (printfn "%s") ``` +If you need direct access to the response stream for some reason (for example to download a large file), you need to write yourself a function and pass it to getResponseStream like so: + +``` fsharp +open System.IO + +let saveToFile (responseStream:Stream) = + use fileStream = new FileStream("c:\\bigImage.png", FileMode.Create) + responseStream.CopyTo(fileStream) + +createRequest Get "http://fsharp.org/img/logo.png" +|> getResponseStream saveToFile +``` +Beware that the stream gets closed, so don't use it outside the scope of the function. + Check out *HttpClient.SampleApplication*, which contains a program demonstrating the library being used and (to some extent) unit tested. *Note* because some of the request and response headers have the same names, to prevent name clashes, the response versions have 'Response' stuck on the end, e.g. @@ -141,6 +155,7 @@ Http.fs attempts to follow [Semantic Versioning](http://semver.org/), which defi * 1.2.0 - Added withKeepAlive * 1.3.0 - Added getResponseBytes, thanks to [Sergeeeek](https://github.com/Sergeeeek) * 1.3.1 - Added project logo, thanks to [sergey-tihon](https://github.com/sergey-tihon) +* 1.4.0 - Added getResponseStream, with thanks to [xkrt](https://github.com/xkrt) ## FAQ ## @@ -203,6 +218,9 @@ Integration tests describe submitting the request and handling the response: * if the response character encoding is specified as 'utf16', uses 'utf-16' instead * cookies are not kept during an automatic redirect * when there is no body, reading it as bytes gives an empty array + * getResponseStream can access the response stream by passing a function + * Closing the response stream retrieved from getResponseStream does not cause an exception + * Trying to access the response stream after getResponseStream causes an ArgumentException ## Why on earth would you make such a thing? ##