webserver-0.4.3: HTTP server library

Network.Web.Server.Basic

Description

Creating basic WebServer. Created WebServer can handle GET / HEAD / POST; OK, Not Found, Not Modified, Moved Permanently, etc; partial getting; language negotication; CGI, chunked data for CGI output;

Synopsis

Documentation

basicServer :: BasicConfig -> WebServerSource

Creating WebServer with BasicConfig. The created WebServer can handle GET / HEAD / POST; OK, Not Found, Not Modified, Moved Permanently, etc; partial getting; language negotication; CGI, chunked data for CGI output; If http://example.com/path does not exist but http://example.com/path/ exists, the created WebServer redirects it. http://example.com/path/ is mapped to /somewhere/path/ by mapper and index.html and index.html.en automatically added and try to read by obtain. If Accept-Language is xx and yy in order, index.html.xx, index.html.yy, index.html and index.html.en are tried. The created WebServer does not dynamically make index.html for a directory even if index.html does not exist for security reasons.

data BasicConfig Source

The configuration for the basic web server.

Constructors

BasicConfig 

Fields

mapper :: URI -> Path

A mapper from URI to Path.

obtain :: FilePath -> Maybe (Integer, Integer) -> IO ByteString

Resource obtaining function. The second argument is (offset of the resource, and length from the offset).

info :: FilePath -> IO (Maybe (Integer, UTCTime))

A function to return the size of the resource and its modification time if exists.

serverName :: ByteString

A server name specified the Server: field.

tcpInfo :: TCPInfo

TCPInfo for passing CGI. (See c10k library.)

data Path Source

Control information of how to handle URI.

Constructors

None

URI cannot be converted into any resources.

File FilePath

URI is converted into a resource (typically a file).

PathCGI CGI

URI is converted into CGI.

Instances

data CGI Source

Internal information of CGI converted from URI.

Constructors

CGI 

Fields

progPath :: FilePath

A porgram path to be executed.

scriptName :: String

A script name.

pathInfo :: String

A path information.

queryString :: String

A query string.

Instances