streamly-http-tls: Fetch http and https URLs with Streamly

[ bsd3, library, network, streamly, web ] [ Propose Tags ] [ Report a vulnerability ]

The convenient face of streamly-http: give a URL, get the response. The scheme chooses between plain TCP and TLS (through streamly-network-tls), and redirects are followed.


[Skip to Readme]

Modules

  • Streamly
    • External
      • Network
        • HTTP
          • Streamly.External.Network.HTTP.TLS

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.19 && <4.22), bytestring (>=0.12 && <0.13), streamly-core (>=0.3.3 && <0.4), streamly-http (>=0.1 && <0.2), streamly-network-tls (>=0.1 && <0.2) [details]
Tested with ghc ==9.8.4 || ==9.10.3 || ==9.12.4
License BSD-3-Clause
Author Xavier Dectot
Maintainer Xavier Dectot <xavier@wheredoibegin.fr>
Uploaded by GdeVolpiano at 2026-11-28T10:43:38Z
Category Network, Web, Streamly
Home page https://github.com/GuillaumedeVolpiano/streamly-http-tls
Source repo head: git clone https://github.com/GuillaumedeVolpiano/streamly-http-tls.git
Distributions
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2026-11-28 [all 1 reports]

Readme for streamly-http-tls-0.1.0.0

[back to package description]

streamly-http-tls

Fetch http and https URLs with Streamly. This is the convenient face of streamly-http: give a URL, get the response. The scheme chooses between plain TCP and TLS (through streamly-network-tls), and redirects are followed.

{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}

import Streamly.Data.Fold qualified as F (length)
import Streamly.Data.Stream (fold)
import Streamly.External.Network.HTTP (Response (..), header)
import Streamly.External.Network.HTTP.TLS (fetchUrl, withUrl)

main :: IO ()
main = do
  -- The whole response in memory.
  response <- fetchUrl "https://example.org/"
  print (response.status, header "content-type" response)

  -- The body as a stream, read while the connection is open.
  arrays <- withUrl "https://example.org/" $ \streamed ->
    fold F.length streamed.body
  print arrays

What it does

  • fetchUrl and withUrl send a GET request and follow the redirects (statuses 301, 302, 303, 307 and 308 with a Location), ten at most.
  • fetchUrlWith and withUrlWith take Options: the certificates trusted for https, the limits of time and size, the number of redirects, and headers for every request. When a redirect leads to another host, Authorization, Proxy-Authorization and Cookie are left out.
  • withResponseAt sends one request of any method, with any body, in clear or over TLS, without following redirects.
  • withSecureClient keeps the connections to every server from one URL to the next: fetchUrlIn and withUrlIn fetch through it. Without a client, each call opens its connections and closes them; the redirects of one call to the same server still share one.
  • withSessionAt keeps one connection to a server, in clear or over TLS, for several requests (fetchIn and withResponseIn of streamly-http): over TLS it spares a handshake for each request after the first.

Limits of this version

  • Those of streamly-http: no content coding decoded, a status is never an error.
  • Each wait is limited, and so is the head of a response (limits in Options). The whole exchange is not: use System.Timeout.timeout. The body is not either by default: set maxBodySize when the server is not trusted.
  • No proxy, no cookie jar.

Building

To build against copies of streamly-http and streamly-network-tls checked out next to this repository, pass --project-file=cabal.project.siblings.