http-client-overrides: HTTP client overrides

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

A library for applying overrides to ManagerSettings when using the http-client library.


[Skip to ReadMe]

Properties

Versions0.1.0.0, 0.1.0.0
Change logNone available
Dependenciesaeson (>=1.0.0.0), base (>=4.7 && <5), bytestring (>=0.10.8.0), http-client (>=0.5.5), http-client-overrides, http-client-tls, http-types (>=0.7.0), network-uri (>=2.6.0.0), text (>=0.3), yaml (>=0.8.11) [details]
LicenseBSD-3-Clause
Copyright2019 Robbie McMichael
AuthorRobbie McMichael
MaintainerRobbie McMichael
CategoryNetwork
Home pagehttps://github.com/githubuser/http-client-overrides
Source repositoryhead: git clone https://github.com/githubuser/http-client-overrides
Executablesexample
UploadedTue Aug 27 04:17:24 UTC 2019 by robbiemcmichael

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees


Readme for http-client-overrides-0.1.0.0

[back to package description]

http-client-overrides

A library for applying overrides to ManagerSettings when using the http-client Haskell library.

Usage

You probably have some IO do notation hidden somewhere which looks like this:

manager <- newManager tlsManagerSettings

Replace it with this:

settings <- withHttpClientOverridesThrow tlsManagerSettings
manager  <- newManager settings

Set the HTTP_CLIENT_OVERRIDES environment variable to the location of your configuration file. When this environment variable is not set there is no additional overhead for HTTP requests as the ManagerSettings will not be modified. Refer to the example directory for a sample Haskell program and configuration file.

Features

Log HTTP requests and responses

The following fields can be used to print log messages for all HTTP responses, requests and request overrides:

version: v1
logOptions:
  responses: simple
  requests: simple
  requestOverrides: simple

The currently supported log formats are simple and detailed. Sample output for the simple log format is shown below:

Overriding request: https://unreachable.domain/ -> https://github.com/
Request: GET https://github.com/ HTTP/1.1
Response: HTTP/1.1 200 OK

Override HTTP requests

Match HTTP requests corresponding to a match URL and transform the request according to an override URL:

version: v1
requestOverrides:
- match: unreachable.domain
  override: github.com

Match semantics

Matches the first HTTP request which:

Any URL segments ommitted from the match URL are not required for matching.

Override semantics

Overrides an HTTP request with:

Any URL segments ommitted from the override URL will not be applied to the HTTP request.

Examples

Override all HTTP requests on port 80 to use HTTPS on port 443 (note: the port is never automatically interpreted from the scheme):

version: v1
requestOverrides:
- match: http://:80
  override: https://:443

Override all requests to the host github.com which have a path prefix of /dhall-lang/dhall-lang/ to use a path prefix of /robbiemcmichael/dhall-lang/ instead.

version: v1
requestOverrides:
- match: https://github.com/dhall-lang/dhall-lang/
  override: https://github.com/robbiemcmichael/dhall-lang/

Debugging

Set logOptions.requestOverrides to detailed to see how the URLs have been parsed and how any matched HTTP requests are being overridden.