| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.HTTP.Proxy
Description
This module contains a simple HTTP and HTTPS proxy. In the most basic setup, the caller specifies a port and runs it as follows:
-- Run a HTTPS and HTTPS proxy on port 3128. import Network.HTTP.Proxy main :: IO () main = runProxy 3128
Synopsis
- type Port = Int
- data Request = Request {}
- data Settings = Settings {
- proxyPort :: Int
- proxyHost :: HostPreference
- proxyOnException :: SomeException -> Response
- proxyTimeout :: Int
- proxyHttpRequestModifier :: Request -> IO (Either Response Request)
- proxyLogger :: ByteString -> IO ()
- proxyUpstream :: Maybe UpstreamProxy
- data UpstreamProxy = UpstreamProxy {
- upstreamHost :: ByteString
- upstreamPort :: Int
- upstreamAuth :: Maybe (ByteString, ByteString)
- httpProxyApp :: Settings -> Manager -> Application
- warpSettings :: Settings -> Settings
- runProxy :: Port -> IO ()
- runProxySettings :: Settings -> IO ()
- runProxySettingsSocket :: Settings -> Socket -> IO ()
- defaultProxySettings :: Settings
Documentation
Constructors
Fields
- requestMethod :: Method
Request method such as GET.
- httpVersion :: HttpVersion
HTTP version such as 1.1.
- requestHeaders :: RequestHeaders
A list of header (a pair of key and value) in an HTTP request.
- requestPath :: ByteString
The part of the URL before the query part.
- queryString :: ByteString
Parsed query string information
Instances
Instances details
Various proxy server settings. This is purposely kept as an abstract data
type so that new settings can be added without breaking backwards
compatibility. In order to create a Settings value, use defaultProxySettings
and record syntax to modify individual records. For example:
defaultProxySettings { proxyPort = 3128 }Constructors
Fields
- proxyPort :: Int
Port to listen on. Default value: 3100
- proxyHost :: HostPreference
Default value: HostIPv4
- proxyOnException :: SomeException -> Response
What to do with exceptions thrown by either the application or server. Default: ignore server-generated exceptions (see
InvalidRequest) and print application-generated applications to stderr. - proxyTimeout :: Int
Timeout value in seconds. Default value: 30
- proxyHttpRequestModifier :: Request -> IO (Either Response Request)
A function that allows the request to be modified before being run. Default: 'return . Right'. This only works for unencrypted HTTP requests (eg to upgrade the request to HTTPS) because HTTPS requests are encrypted.
- proxyLogger :: ByteString -> IO ()
A function for logging proxy internal state. Default: 'return ()'.
- proxyUpstream :: Maybe UpstreamProxy
Optional upstream proxy.
data UpstreamProxy Source #
A http-proxy can be configured to use and upstream proxy by providing the proxy name, the port it listens to and an option username and password for proxy authorisation.
Constructors
Fields
- upstreamHost :: ByteString
The upstream proxy's hostname.
- upstreamPort :: Int
The upstream proxy's port number.
- upstreamAuth :: Maybe (ByteString, ByteString)
Optional username and password to use with upstream proxy.
httpProxyApp :: Settings -> Manager -> Application Source #
warpSettings :: Settings -> Settings Source #
runProxy :: Port -> IO () Source #
Run a HTTP and HTTPS proxy server on the specified port. This calls
runProxySettings with defaultProxySettings .
runProxySettings :: Settings -> IO () Source #
Run a HTTP and HTTPS proxy server with the specified settings.
defaultProxySettings :: Settings Source #
The default settings for the Proxy server. See the individual settings for the default value.