HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

ModuleHTTP-4000.4.1Haskell98

Network.HTTP.Base

Definitions of Request and Response types along with functions for normalizing them. It is assumed to be an internal module; user code should, if possible, import Network.HTTP to access the functionality that this module provides.

Additionally, the module exports internal functions for working with URLs, and for handling the processing of requests and responses coming back.

  • 14 types
  • 40 values
  • PackageHTTP-4000.4.1
  • Exports54
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceBase.hs

Constants

1 declaration

HTTP

7 declarations
datadata Request a
#

An HTTP Request. The Show instance of this type is used for message serialisation, which means no body data is output.

Constructors

Instances2Show, HasHeaders
datadata Response a
#

An HTTP Response. The Show instance of this type is used for message serialisation, which means no body data is output, additionally the output will show an HTTP version of 1.1 instead of the actual version returned by a server.

Instances2Show, HasHeaders

URL Encoding

3 declarations

URI authority parsing

43 declarations

Parse the authority part of a URL.

RFC 1732, section 3.1:

      //<user>:<password>@<host>:<port>/<url-path>
 Some or all of the parts "<user>:<password>@", ":<password>",
 ":<port>", and "/<url-path>" may be excluded.
typetype ResponseCode = (Int, Int, Int)
#

For easy pattern matching, HTTP response codes xyz are represented as (x,y,z).

typetype RequestData = (RequestMethod, URI, [Header])
#

RequestData contains the head of a HTTP request; method, its URL along with the auxiliary/supporting header data.

valuehopefulTransfer
  1. :: BufferOp a
  2. -> IO (Result a)
  3. -> [a]
  4. -> IO (Result ([Header], a))
#

Used when nothing about data is known, Unfortunately waiting for a socket closure causes bad behaviour. Here we just take data once and give up the rest.

valuereadTillEmpty2 :: BufferOp a -> IO (Result a) -> [a] -> IO (Result [a])
#

Read lines until an empty line (CRLF), also accepts a connection close as end of input, which is not an HTTP/1.1 compliant thing to do - so probably indicates an error condition.

valuemkRequest :: BufferType ty => RequestMethod -> URI -> Request ty
#

'mkRequest method uri' constructs a well formed request for the given HTTP method and URI. It does not normalize the URI for the request _nor_ add the required Host: header. That is done either explicitly by the user or when requests are normalized prior to transmission.

A default user agent string. The string is "haskell-HTTP/$version" where $version is the version of this HTTP package.

The version of this HTTP package as a string, e.g. "4000.1.2". This may be useful to include in a user agent string so that you can determine from server logs what version of this package HTTP clients are using. This can be useful for tracking down HTTP compatibility quirks.

valuecatchIO :: IO a -> (IOException -> IO a) -> IO a
#

catchIO a h handles IO action exceptions throughout codebase; version-specific tweaks better go here.