Skip to content
Elixir Stream around HTTPoison async response
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
test
.formatter.exs
.gitignore
README.md
bench_lines.exs
memory_test.exs
mix.exs
mix.lock
numbers_small.txt
sum_30_lines.exs
sum_numbers.exs

README.md

HTTPStream

Wouldn’t be great to process a large HTTP response, in chunks, with Elixir streams?

HTTPStream.get("https://.../large_image.tiff")
|> StreamGzip.gzip
|> Stream.into(File.stream!("image.tiff.gz"))
|> Stream.run

Or process a huge remote text files line by line, on the fly?

"https://.../numbers.txt"
|> HTTPStream.get()
|> HTTPStream.lines()
|> Stream.map(...)
|> Enum.sum()

In these two articles we see how to build an Elixir Stream around a HTTPoison async response so we can take advantage of streams lazyness and composability.

This code is just meant as an experiment and it's not intended to be used in production!

You can’t perform that action at this time.