gi-soup-3.0.2: Libsoup bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Soup.Objects.ServerMessage

Description

An HTTP server request and response pair.

A SoupServerMessage represents an HTTP message that is being sent or received on a [classserver].

classserver
will create SoupServerMessages automatically for incoming requests, which your application will receive via handlers.

Note that libsoup's terminology here does not quite match the HTTP specification: in RFC 2616, an "HTTP-message" is *either* a Request, *or* a Response. In libsoup, a ServerMessage combines both the request and the response.

Synopsis

Exported types

newtype ServerMessage Source #

Memory-managed wrapper type.

Constructors

ServerMessage (ManagedPtr ServerMessage) 

Instances

Instances details
Eq ServerMessage Source # 
Instance details

Defined in GI.Soup.Objects.ServerMessage

GObject ServerMessage Source # 
Instance details

Defined in GI.Soup.Objects.ServerMessage

ManagedPtrNewtype ServerMessage Source # 
Instance details

Defined in GI.Soup.Objects.ServerMessage

Methods

toManagedPtr :: ServerMessage -> ManagedPtr ServerMessage

TypedObject ServerMessage Source # 
Instance details

Defined in GI.Soup.Objects.ServerMessage

Methods

glibType :: IO GType

HasParentTypes ServerMessage Source # 
Instance details

Defined in GI.Soup.Objects.ServerMessage

IsGValue (Maybe ServerMessage) Source #

Convert ServerMessage to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Soup.Objects.ServerMessage

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe ServerMessage -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe ServerMessage)

type ParentTypes ServerMessage Source # 
Instance details

Defined in GI.Soup.Objects.ServerMessage

type ParentTypes ServerMessage = '[Object]

class (GObject o, IsDescendantOf ServerMessage o) => IsServerMessage o Source #

Type class for types which can be safely cast to ServerMessage, for instance with toServerMessage.

Instances

Instances details
(GObject o, IsDescendantOf ServerMessage o) => IsServerMessage o Source # 
Instance details

Defined in GI.Soup.Objects.ServerMessage

toServerMessage :: (MonadIO m, IsServerMessage o) => o -> m ServerMessage Source #

Cast to ServerMessage, for types for which this is known to be safe. For general casts, use castTo.

Methods

getHttpVersion

serverMessageGetHttpVersion Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m HTTPVersion

Returns: a HTTPVersion.

Get the HTTP version of msg.

getLocalAddress

serverMessageGetLocalAddress Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m (Maybe SocketAddress)

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

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

getMethod

serverMessageGetMethod Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m Text

Returns: the HTTP method.

Get the HTTP method of msg.

getReasonPhrase

serverMessageGetReasonPhrase Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage:

-> m (Maybe Text)

Returns: the reason phrase.

Get the HTTP reason phrase of msg.

getRemoteAddress

serverMessageGetRemoteAddress Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m (Maybe SocketAddress)

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

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

getRemoteHost

serverMessageGetRemoteHost Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m (Maybe Text)

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

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

getRequestBody

serverMessageGetRequestBody Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m MessageBody

Returns: a MessageBody.

Get the request body of msg.

getRequestHeaders

serverMessageGetRequestHeaders Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m MessageHeaders

Returns: a MessageHeaders with the request headers.

Get the request headers of msg.

getResponseBody

serverMessageGetResponseBody Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m MessageBody

Returns: a MessageBody.

Get the response body of msg.

getResponseHeaders

serverMessageGetResponseHeaders Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m MessageHeaders

Returns: a MessageHeaders with the response headers.

Get the response headers of msg.

getSocket

serverMessageGetSocket Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m (Maybe Socket)

Returns: the Socket that msg is associated with, Nothing if you used [methodserver.accept_iostream].

Retrieves the Socket that msg 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.

getStatus

serverMessageGetStatus Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m Word32

Returns: the HTTP status code.

Get the HTTP status code of msg.

getTlsPeerCertificate

serverMessageGetTlsPeerCertificate Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a Message

-> m (Maybe TlsCertificate)

Returns: msg's TLS peer certificate, or Nothing if msg's connection is not SSL.

Gets the peer's TlsCertificate associated with msg's connection. Note that this is not set yet during the emission of SoupServerMessageacceptCertificate signal.

Since: 3.2

getTlsPeerCertificateErrors

serverMessageGetTlsPeerCertificateErrors Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a Message

-> m [TlsCertificateFlags]

Returns: a TlsCertificateFlags with msg's TLS peer certificate errors.

Gets the errors associated with validating msg's TLS peer certificate. Note that this is not set yet during the emission of SoupServerMessageacceptCertificate signal.

Since: 3.2

getUri

serverMessageGetUri Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m Uri

Returns: a Uri

Get msg's URI.

isOptionsPing

serverMessageIsOptionsPing Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m Bool

Returns: True if is an OPTIONS ping

Gets if msg represents an OPTIONS message with the path *.

pause

serverMessagePause Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a SoupServerMessage

-> m () 

Pauses I/O on msg.

This can be used when you need to return from the server handler without having the full response ready yet. Use [methodserverMessage.unpause] to resume I/O.

Since: 3.2

setHttpVersion

serverMessageSetHttpVersion Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> HTTPVersion

version: a HTTPVersion

-> m () 

Set the HTTP version of msg.

setRedirect

serverMessageSetRedirect Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> Word32

statusCode: a 3xx status code

-> Text

redirectUri: the URI to redirect msg to

-> m () 

Sets msg's status_code to statusCode and adds a Location header pointing to redirectUri. Use this from a [classserver] when you want to redirect the client to another URI.

redirectUri can be a relative URI, in which case it is interpreted relative to msg's current URI. In particular, if redirectUri is just a path, it will replace the path *and query* of msg's URI.

setResponse

serverMessageSetResponse Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: the message

-> Maybe Text

contentType: MIME Content-Type of the body

-> MemoryUse

respUse: a MemoryUse describing how to handle respBody

-> Maybe ByteString

respBody: a data buffer containing the body of the message response.

-> m () 

Convenience function to set the response body of a ServerMessage. If contentType is Nothing, the response body must be empty as well.

setStatus

serverMessageSetStatus Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> Word32

statusCode: an HTTP status code

-> Maybe Text

reasonPhrase: a reason phrase

-> m () 

Sets msg's status code to statusCode.

If statusCode is a known value and reasonPhrase is Nothing, the reason_phrase will be set automatically.

stealConnection

serverMessageStealConnection Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a ServerMessage

-> m IOStream

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

"Steals" the HTTP connection associated with msg from its Server. This happens immediately, regardless of the current state of the connection; if the response to msg has not yet finished being sent, then it will be discarded; you can steal the connection from a signalserverMessage[wroteInformational] or signalserverMessage[wroteBody] 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, msg will most likely be freed as a side effect.

unpause

serverMessageUnpause Source #

Arguments

:: (HasCallStack, MonadIO m, IsServerMessage a) 
=> a

msg: a SoupServerMessage

-> m () 

Resumes I/O on msg.

Use this to resume after calling [methodserverMessage.pause], or after adding a new chunk to a chunked response. I/O won't actually resume until you return to the main loop.

Since: 3.2

Properties

tlsPeerCertificate

The peer's TlsCertificate associated with the message

Since: 3.2

getServerMessageTlsPeerCertificate :: (MonadIO m, IsServerMessage o) => o -> m (Maybe TlsCertificate) Source #

Get the value of the “tls-peer-certificate” property. When overloading is enabled, this is equivalent to

get serverMessage #tlsPeerCertificate

tlsPeerCertificateErrors

The verification errors on ServerMessage:tlsPeerCertificate

Since: 3.2

getServerMessageTlsPeerCertificateErrors :: (MonadIO m, IsServerMessage o) => o -> m [TlsCertificateFlags] Source #

Get the value of the “tls-peer-certificate-errors” property. When overloading is enabled, this is equivalent to

get serverMessage #tlsPeerCertificateErrors

Signals

acceptCertificate

type ServerMessageAcceptCertificateCallback Source #

Arguments

 = TlsCertificate

tlsPeerCertificate: the peer's TlsCertificate

-> [TlsCertificateFlags]

tlsPeerErrors: the tls errors of tlsCertificate

-> IO Bool

Returns: True to accept the TLS certificate and stop other handlers from being invoked, or False to propagate the event further.

Emitted during the msg's connection TLS handshake after client TLS certificate has been received. You can return True to accept tlsCertificate despite tlsErrors.

afterServerMessageAcceptCertificate :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageAcceptCertificateCallback) -> m SignalHandlerId Source #

Connect a signal handler for the acceptCertificate signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #acceptCertificate callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageAcceptCertificate :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageAcceptCertificateCallback) -> m SignalHandlerId Source #

Connect a signal handler for the acceptCertificate signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #acceptCertificate callback

connected

type ServerMessageConnectedCallback = IO () Source #

Emitted when the msg's socket is connected and the TLS handshake completed.

afterServerMessageConnected :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageConnectedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the connected signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #connected callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageConnected :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageConnectedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the connected signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #connected callback

disconnected

type ServerMessageDisconnectedCallback = IO () Source #

Emitted when the msg's socket is disconnected.

afterServerMessageDisconnected :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageDisconnectedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the disconnected signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #disconnected callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageDisconnected :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageDisconnectedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the disconnected signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #disconnected callback

finished

type ServerMessageFinishedCallback = IO () Source #

Emitted when all HTTP processing is finished for a message. (After signalserverMessage[wroteBody]).

afterServerMessageFinished :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageFinishedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the finished signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #finished callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageFinished :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageFinishedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the finished signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #finished callback

gotBody

type ServerMessageGotBodyCallback = IO () Source #

Emitted after receiving the complete request body.

afterServerMessageGotBody :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageGotBodyCallback) -> m SignalHandlerId Source #

Connect a signal handler for the gotBody signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #gotBody callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageGotBody :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageGotBodyCallback) -> m SignalHandlerId Source #

Connect a signal handler for the gotBody signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #gotBody callback

gotChunk

type ServerMessageGotChunkCallback Source #

Arguments

 = Bytes

chunk: the just-read chunk

-> IO () 

Emitted after receiving a chunk of a message body.

Note that "chunk" in this context means any subpiece of the body, not necessarily the specific HTTP 1.1 chunks sent by the other side.

afterServerMessageGotChunk :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageGotChunkCallback) -> m SignalHandlerId Source #

Connect a signal handler for the gotChunk signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #gotChunk callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageGotChunk :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageGotChunkCallback) -> m SignalHandlerId Source #

Connect a signal handler for the gotChunk signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #gotChunk callback

gotHeaders

type ServerMessageGotHeadersCallback = IO () Source #

Emitted after receiving the Request-Line and request headers.

afterServerMessageGotHeaders :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageGotHeadersCallback) -> m SignalHandlerId Source #

Connect a signal handler for the gotHeaders signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #gotHeaders callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageGotHeaders :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageGotHeadersCallback) -> m SignalHandlerId Source #

Connect a signal handler for the gotHeaders signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #gotHeaders callback

wroteBody

type ServerMessageWroteBodyCallback = IO () Source #

Emitted immediately after writing the complete response body for a message.

afterServerMessageWroteBody :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageWroteBodyCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wroteBody signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #wroteBody callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageWroteBody :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageWroteBodyCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wroteBody signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #wroteBody callback

wroteBodyData

type ServerMessageWroteBodyDataCallback Source #

Arguments

 = Word32

chunkSize: the number of bytes written

-> IO () 

Emitted immediately after writing a portion of the message body to the network.

afterServerMessageWroteBodyData :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageWroteBodyDataCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wroteBodyData signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #wroteBodyData callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageWroteBodyData :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageWroteBodyDataCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wroteBodyData signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #wroteBodyData callback

wroteChunk

type ServerMessageWroteChunkCallback = IO () Source #

Emitted immediately after writing a body chunk for a message.

Note that this signal is not parallel to signalserverMessage[gotChunk]; it is emitted only when a complete chunk (added with [methodmessageBody.append] or [methodmessageBody.append_bytes] has been written. To get more useful continuous progress information, use signalserverMessage[wroteBodyData].

afterServerMessageWroteChunk :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageWroteChunkCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wroteChunk signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #wroteChunk callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageWroteChunk :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageWroteChunkCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wroteChunk signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #wroteChunk callback

wroteHeaders

type ServerMessageWroteHeadersCallback = IO () Source #

Emitted immediately after writing the response headers for a message.

afterServerMessageWroteHeaders :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageWroteHeadersCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wroteHeaders signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #wroteHeaders callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageWroteHeaders :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageWroteHeadersCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wroteHeaders signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #wroteHeaders callback

wroteInformational

type ServerMessageWroteInformationalCallback = IO () Source #

Emitted immediately after writing a 1xx (Informational) response.

afterServerMessageWroteInformational :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageWroteInformationalCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wroteInformational signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after serverMessage #wroteInformational callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onServerMessageWroteInformational :: (IsServerMessage a, MonadIO m) => a -> ((?self :: a) => ServerMessageWroteInformationalCallback) -> m SignalHandlerId Source #

Connect a signal handler for the wroteInformational signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on serverMessage #wroteInformational callback