[ bsd3, library, web ] [ Propose Tags ]

"HTTP client for haskell, inpired by requests and http-dispatch."

[Skip to Readme]


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,,,,,
Dependencies base (>=4.7 && <5), bytestring (>=0.10.12 && <0.12), case-insensitive (>=1.2.1 && <1.3), http-client (>=0.6.4 && <0.8), http-client-tls (>=0.3.5 && <0.4), http-types (>=0.12.3 && <0.13) [details]
License BSD-3-Clause
Copyright 2020 An Long
Author An Long
Category Web
Home page
Source repo head: git clone
Uploaded by asaka at 2023-12-06T09:04:37Z
Downloads 949 total (21 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-12-06 [all 1 reports]

Readme for request-

[back to package description]


HTTP client for haskell, inpired by requests and http-dispatch.


This pacakge is published on hackage with the same name request, you can install it with cabal or stack or nix as any other hackage packages.


You can try this in haskell REPL once you have request installed:

import Network.HTTP.Request

resp <- get ""
print $ requestStatus resp

Core API

Request's API has three core concepts: Request record type, Response record type, send function.


Request is all about the information you will send to the target URL.

data Request = Request
  { requestMethod  :: Method
  , requestUrl     :: String
  , requestHeaders :: Headers
  , requestBody    :: Maybe Data.ByteString.ByteString
  } deriving (Show)


Once you have constructed your own Request record, you can call the send function to send it to the server. The send function's type is:

send :: Request -> IO Response


Response is what you got from the server URL.

data Response = Response
  { responseStatus  :: Int
  , responseHeaders :: Headers
  , responseBody    :: Data.ByteString.ByteString
  } deriving (Show)


:set -XOverloadedStrings

import Network.HTTP.Request

-- Construct a Request record.
let req = Request GET "" [] Nothing
-- Send it.
res <- send req
-- access the fields on Response.
print $ requestStatus resp


As you expected, there are some shortcuts for the most used scenarios.

get :: String -> IO Response
get url =
  send $ Request GET url [] Nothing

delete :: String -> IO Response
delete url =
  send $ Request DELETE url [] Nothing

post :: (String, Maybe Data.ByteString.ByteString) -> IO Response
post (url, body) =
  send $ Request POST url [] body

put :: (String, Maybe Data.ByteString.ByteString) -> IO Response
put (url, body) =
  send $ Request PUT url [] body

These shortcuts' definitions are simple and direct. You are encouraged to add your own if the built-in does not match your use cases, like add custom headers in every request.

API Documents

See the hackage page:

About the Project

Request is © 2020-2021 by aisk.


Request is distributed by a BSD license.