snap-server-1.0.3.3: A web server for the Snap Framework

Safe HaskellNone
LanguageHaskell2010

Snap.Internal.Http.Server.Types

Contents

Description

Types internal to the implementation of the Snap HTTP server.

Synopsis

Documentation

data ServerConfig hookState Source #

Data and services that all HTTP response handlers share.

Constructors

ServerConfig 

Fields

data PerSessionData Source #

All of the things a session needs to service a single HTTP request.

Constructors

PerSessionData 

Fields

type DataFinishedHook hookState = IORef hookState -> Request -> Response -> IO () Source #

The DataFinishedHook is called once the server has finished sending the HTTP response to the client.

type EscapeSnapHook hookState = IORef hookState -> IO () Source #

The EscapeSnapHook is called if the user handler escapes the HTTP session, e.g. for websockets.

type ExceptionHook hookState = IORef hookState -> SomeException -> IO () Source #

The ExceptionHook is called if an exception reaches the toplevel of the server, i.e. if an exception leaks out of the user handler or if an exception is raised during the sending of the HTTP response data.

type ParseHook hookState = IORef hookState -> Request -> IO () Source #

The ParseHook is called after the HTTP Request has been parsed by the server, but before the user handler starts running.

type NewRequestHook hookState = PerSessionData -> IO hookState Source #

The NewRequestHook is called once processing for an HTTP request begins, i.e. after the connection has been accepted and we know that there's data available to read from the socket. The IORef passed to the hook initially contains a bottom value that will throw an exception if evaluated.

type UserHandlerFinishedHook hookState = IORef hookState -> Request -> Response -> IO () Source #

The UserHandlerFinishedHook is called once the user handler has finished running, but before the data for the HTTP response starts being sent to the client.

Handlers

type SendFileHandler Source #

Arguments

 = Buffer

builder buffer

-> Builder

status line and headers

-> FilePath

file to send

-> Word64

start offset

-> Word64

number of bytes

-> IO () 

A SendFileHandler is called if the user handler requests that a file be sent using sendfile() on systems that support it (Linux, Mac OSX, and FreeBSD).

type ServerHandler hookState Source #

Arguments

 = ServerConfig hookState

global server config

-> PerSessionData

per-connection data

-> Request

HTTP request object

-> IO (Request, Response) 

This function, provided to the web server internals from the outside, is responsible for producing a Response once the server has parsed the Request.

Socket types

data SocketConfig Source #

Either the server should start listening on the given interface / port combination, or the server should start up with a Socket that has already had bind() and listen() called on it.