Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
A ClientContext
provides additional information about the
client making a particular request. In particular, you can use
clientContextGetAuthDomain
and
clientContextGetAuthUser
to determine if HTTP
authentication was used successfully.
clientContextGetRemoteAddress
and/or
clientContextGetHost
can be used to get information for
logging or debugging purposes. clientContextGetGsocket
may
also be of use in some situations (eg, tracking when multiple
requests are made on the same connection).
- newtype ClientContext = ClientContext (ManagedPtr ClientContext)
- noClientContext :: Maybe ClientContext
- clientContextGetAddress :: (HasCallStack, MonadIO m) => ClientContext -> m (Maybe Address)
- clientContextGetAuthDomain :: (HasCallStack, MonadIO m) => ClientContext -> m (Maybe AuthDomain)
- clientContextGetAuthUser :: (HasCallStack, MonadIO m) => ClientContext -> m (Maybe Text)
- clientContextGetGsocket :: (HasCallStack, MonadIO m) => ClientContext -> m (Maybe Socket)
- clientContextGetHost :: (HasCallStack, MonadIO m) => ClientContext -> m (Maybe Text)
- clientContextGetLocalAddress :: (HasCallStack, MonadIO m) => ClientContext -> m (Maybe SocketAddress)
- clientContextGetRemoteAddress :: (HasCallStack, MonadIO m) => ClientContext -> m (Maybe SocketAddress)
- clientContextGetSocket :: (HasCallStack, MonadIO m) => ClientContext -> m Socket
- clientContextStealConnection :: (HasCallStack, MonadIO m) => ClientContext -> m IOStream
Exported types
newtype ClientContext Source #
Methods
getAddress
clientContextGetAddress Source #
:: (HasCallStack, MonadIO m) | |
=> ClientContext |
|
-> m (Maybe Address) | Returns: the |
Deprecated: Use clientContextGetRemoteAddress
, which returnsa SocketAddress
.
Retrieves the Address
associated with the remote end
of a connection.
getAuthDomain
clientContextGetAuthDomain Source #
:: (HasCallStack, MonadIO m) | |
=> ClientContext |
|
-> m (Maybe AuthDomain) | Returns: a |
Checks whether the request associated with client
has been
authenticated, and if so returns the AuthDomain
that
authenticated it.
getAuthUser
clientContextGetAuthUser Source #
:: (HasCallStack, MonadIO m) | |
=> ClientContext |
|
-> m (Maybe Text) | Returns: the authenticated-as user, or |
Checks whether the request associated with client
has been
authenticated, and if so returns the username that the client
authenticated as.
getGsocket
clientContextGetGsocket Source #
:: (HasCallStack, MonadIO m) | |
=> ClientContext |
|
-> m (Maybe Socket) | Returns: the |
Retrieves the Socket
that client
is associated with.
If you are using this method to observe when multiple requests are made on the same persistent HTTP connection (eg, as the ntlm-test test program does), you will need to pay attention to socket destruction as well (eg, by using weak references), so that you do not get fooled when the allocator reuses the memory address of a previously-destroyed socket to represent a new socket.
Since: 2.48
getHost
:: (HasCallStack, MonadIO m) | |
=> ClientContext |
|
-> m (Maybe Text) | Returns: the IP address associated with the remote
end of a connection, it may be |
Retrieves the IP address associated with the remote end of a connection.
getLocalAddress
clientContextGetLocalAddress Source #
:: (HasCallStack, MonadIO m) | |
=> ClientContext |
|
-> m (Maybe SocketAddress) | Returns: the |
Retrieves the SocketAddress
associated with the local end
of a connection.
Since: 2.48
getRemoteAddress
clientContextGetRemoteAddress Source #
:: (HasCallStack, MonadIO m) | |
=> ClientContext |
|
-> m (Maybe SocketAddress) | Returns: the |
Retrieves the SocketAddress
associated with the remote end
of a connection.
Since: 2.48
getSocket
clientContextGetSocket Source #
:: (HasCallStack, MonadIO m) | |
=> ClientContext |
|
-> m Socket | Returns: the |
Deprecated: use clientContextGetGsocket
, which returnsa Socket
.
Retrieves the Socket
that client
is associated with.
If you are using this method to observe when multiple requests are
made on the same persistent HTTP connection (eg, as the ntlm-test
test program does), you will need to pay attention to socket
destruction as well (either by using weak references, or by
connecting to the Socket
::disconnected
signal), so that you do
not get fooled when the allocator reuses the memory address of a
previously-destroyed socket to represent a new socket.
stealConnection
clientContextStealConnection Source #
:: (HasCallStack, MonadIO m) | |
=> ClientContext |
|
-> m IOStream | Returns: the |
"Steals" the HTTP connection associated with client
from its
Server
. This happens immediately, regardless of the current
state of the connection; if the response to the current
Message
has not yet finished being sent, then it will be
discarded; you can steal the connection from a
Message
:wrote-informational
or Message
:wrote-body
signal
handler if you need to wait for part or all of the response to be
sent.
Note that when calling this function from C, client
will most
likely be freed as a side effect.
Since: 2.50