gi-soup-2.4.21: Libsoup bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (inaki@blueleaf.cc)
Safe HaskellNone
LanguageHaskell2010

GI.Soup.Structs.ClientContext

Contents

Description

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).

Synopsis

Exported types

newtype ClientContext Source #

Memory-managed wrapper type.

Instances
BoxedObject ClientContext Source # 
Instance details

Defined in GI.Soup.Structs.ClientContext

Methods

getAddress

clientContextGetAddress Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ClientContext

client: a ClientContext

-> m (Maybe Address)

Returns: the Address associated with the remote end of a connection, it may be Nothing if you used serverAcceptIostream.

Deprecated: Use clientContextGetRemoteAddress, which returnsa SocketAddress.

Retrieves the Address associated with the remote end of a connection.

getAuthDomain

clientContextGetAuthDomain Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ClientContext

client: a ClientContext

-> m (Maybe AuthDomain)

Returns: a AuthDomain, or Nothing if the request was not authenticated.

Checks whether the request associated with client has been authenticated, and if so returns the AuthDomain that authenticated it.

getAuthUser

clientContextGetAuthUser Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ClientContext

client: a ClientContext

-> m (Maybe Text)

Returns: the authenticated-as user, or Nothing if the request was not authenticated.

Checks whether the request associated with client has been authenticated, and if so returns the username that the client authenticated as.

getGsocket

clientContextGetGsocket Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ClientContext

client: a ClientContext

-> m (Maybe Socket)

Returns: the Socket that client is associated with, Nothing if you used serverAcceptIostream.

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

clientContextGetHost Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ClientContext

client: a ClientContext

-> m (Maybe Text)

Returns: the IP address associated with the remote end of a connection, it may be Nothing if you used serverAcceptIostream.

Retrieves the IP address associated with the remote end of a connection.

getLocalAddress

clientContextGetLocalAddress Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ClientContext

client: a ClientContext

-> m (Maybe SocketAddress)

Returns: the SocketAddress associated with the local end of a connection, it may be Nothing if you used serverAcceptIostream.

Retrieves the SocketAddress associated with the local end of a connection.

Since: 2.48

getRemoteAddress

clientContextGetRemoteAddress Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ClientContext

client: a ClientContext

-> m (Maybe SocketAddress)

Returns: the SocketAddress associated with the remote end of a connection, it may be Nothing if you used serverAcceptIostream.

Retrieves the SocketAddress associated with the remote end of a connection.

Since: 2.48

getSocket

clientContextGetSocket Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ClientContext

client: a ClientContext

-> m Socket

Returns: the Socket that client is associated with.

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 #

Arguments

:: (HasCallStack, MonadIO m) 
=> ClientContext

client: a ClientContext

-> m IOStream

Returns: the IOStream formerly associated with client (or Nothing if client was no longer associated with a connection). No guarantees are made about what kind of IOStream is returned.

"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