Common Lisp Package: CL-CHESHIRE-CAT

Cheshire Cat (HTTP Redirection Server) main package

README:

Summary

cl-cheshire-cat is a project for a CL redirection server.

The core of the server is based on Edi Weitz (http://weitz.de/) CL librairies, in particular:

  • Hunchentoot (Web Server)
  • CL-PPCRE

The persistence layer is ensured using CL-STORE (http://common-lisp.net/project/cl-store).

Installation

The recommended way to install cheshire is by using quicklisp as much as possible:

  1. Using quicklisp, you can install:
  • hunchentoot
  • cl-store
  • split-sequence
  1. You need to manually install sb-daemon

If you use the provided cheshire.sh and cheshire.lisp, you also need to install py-configparser (available via quicklisp).

How to use

The recommended usage requires you to use SBCL (and optionnaly swank) and is divided in a three component process:

  1. The cheshire.sh script which is responsible for daemon management operations.
  2. The cheshire.lisp script which is responsible for loading and starting the cheshire daemon.
  3. The daemon itself.

You are encouraged to modify and adapt the first two component in the way most convinient to your own use of the Cheshire.

As mentionned, the default process is dependent on SBCL. However we would like Cheshire to be compatible with as many CL distributions as possible. Any adaptation of the starting process be compatible with a different CL distribution is welcome.

cheshire.sh

The daemon operations are performed using scripts/cheshire.sh. The first argument of the script is either start, stop, restart or status and makes the script perform the appropriate action. The script should always be executed as root.

If you copy this script directly into /etc/init.d/, there is a slight possibility that the script will run when started as root, but not at boot time (e.g. on Debian 6.0). In this case, you will need to specify locale and/or home in the configuration file. That's because the environment is not exactly the same one when the service is started at boot time.

Second, if you see that the error log is populated with messages "Cannot open such file" or "Cannot create such directory" when you use daemonize and privilege dropping, make sure all the directories Cheshire tries to right into are owned by the appropriate user. This include in particular home/.cache, home/.slime and their sub-directories.

The second argument is expected to be a configuration file. If none is given, /etc/cheshire.conf is the default configuration file.

cheshire.sh is looking for a pidfile= entry in the configuration file. If there is no such entry, /var/run/cheshire.pid is used.

The required action is then performed by cheshire.sh. If it needs to run the server, it assumes that scripts/cheshire.lisp is located as /usr/share/cheshire/scripts/cheshire.lisp unless it finds a system= directive in the configuration file.

cheshire.lisp

cheshire.lisp is loading the configuration file and starting the daemon. (Please refer to config/cheshire.conf for the details of the documentation). cheshire.lisp expects the configuration file as its first command-line argument and assumes that the cl-cheshire-cat system is loadable via (asdf:load-system "cl-cheshire-cat").

The starting process includes:

  1. starting to listen on the specified port
  2. daemon bookeeping (debugging, dropping privileges, swank loading)
  3. loading the redirection rules

The privileges are dropped after Cheshire started listening. This is a limitation from usocket and hunchentoot. This means:

  • you should not have any problem listening directly on the 80 port (or any other privileged port).
  • the few first requests could happen to be served as root. Since the redirection specifications is not loaded untill the privileges are dropped and this issue can be prevented by a system firewall (like iptables), we don't consider it a big security issue.

Customization

If the recommended usage does not fit your use of Cheshire, feel free to adapt any of the previously described steps. They are made to be highly and easily customizable.

Note that the debugging bookeeping step in cheshire.lisp is provided for convinience. If you skip this part, Hunchentoot defaults will be used:

  • the debugger will never be called in case of an error
  • error pages will show complete error message and backtrace

Behavior

The server is listening on the HTTP port (80), awaiting an HTTP query. Other ports will work, but you must keep in mind that no port rewritting facility is currently offered.

The server first search for a domain name rule to apply and then for a URI rewritting rule. The details of each rule is descript is the following section.

The rules are always checked in turn, if a rule matches, it's applied (and the search stop).

If no domain name matching rule is found and the domain name does not start with www., the server will send a "301 Moved Permanently" to the same URL with an additional www. prefix to domain name. If the domain name already starts with www., the server will return a "404 Not Found" error in order to avoid redirection loop.

If a domain name rule matched, Cheshire then search its list of URI rule to apply any addition URI modification. If there is no URI matching rule and no domain rewritting in effect, the server will return a "404 Not Found" error in order to prevent redirection loops.

Domain name rules parameters are used as default for its associated URI rules.

The loop protections intend to protect you from mild obvious rule specification errors. Their goal is not to prevent willingful redirection loops or mischievious configurations. For example it is easy to trick Cheshire into issuing infinite redirection loops with a domain name rule with no URI rule, key (:exact "www.domain.example") and replacement "www.domain.example". In other words you are responsible for the correctness of your redirection rules. Cheshire will not check them for you and there is no plan to do so in the future.

Unspecified behavior

Since Cheshire intends to be a production-grade product, we made our best to keep unspecified behavior implementation on a fail-early and safe basis.

For example, if you provide an invalid argument for a rule specification, we try to fail and send an error message when you create or update the rule rather than at apply time.

However, this behavior may not be always easy to have, don't forget that unspecified behaviour is still unspecified and may make Cheshire to crash on each and every request it receives.

Rules

Each rule is composed of two main elements:

  • The rule's key is identifying whether the rule can be applied to a given URL. The key is itself composed of two elements:
  • The kind specifies the algorithm used to match the rule.
  • The match specification gives the information to match the rule against the URL.
  • The rule's effect including the modification to apply to the matching URL, options for the HTTP Answer or subsequent rules to apply.

Domain rules

Key

Three rules matching algorithms (kinds) are used:

  • exact
  • suffix (matches if the end of the domain name matches)
  • regex

Following the DNS specification ([RFC1035]), domain name matches are always case-insensitive.

Effect

Domain rewritting

If the rewrite specification is not nil, the domain will be rewritten.

If the rule is an exact match, the rewritte specification is use to replace the whole domain name.

If the rule is a suffix match, the rewritte specification may contain once the special substring "\1", which will be replaced by the prefix (non matching part) of the original domain name.

If the rule is a regex match, any string replacement accepted by cl-ppcre:regex-replace will be accepted and the result will be equivalent to (cl-ppcre:regex-replace regex original-domain-name replacement). Function designators are not allowed since they cannot be saved easily.

URI rules

A list of URI rewritting rules can be used for each domain.

Key

Three rules matching algorithms (kinds) are used:

  • exact
  • prefix (matches if the beggining of the URI matches)
  • regex

URI match are case-sensitive by default (this can be changed via regex flags).

URI replacements for exact and regex match occurs the same way as Domain rewritting.

If the rule is a prefix match, the rewritte specification may contain once the special substring "\1", which will be replaced by the suffix (non matching part) of the original URI.

Redirection parameters

Each redirection specification can also include redirection parameters.

HTTP Status Code

The first parameter supported is http-code and its default value is 301.

http-code must be one of 300, 301 (default), 302, 303 or 307. This status code will be the one used in the answer sent to the client. The behavior is unspecified if an invalid status code specification is given.

HTTP/HTTPS Protocol

The second parameter is protocol and its default value is http.

protocol must be one of http or https and it is the protocol that will be used as the redirection target.

Port

The third and last parameter is port and its default depends on the value of protocol (443 if protocol is https, 80 otherwise).

port must be a valid port number (i.e. an integer between 1 and 63565).

Query string manipulation

Each rule can be given a list of query string manipulation to do. These operations are run before any rewritting occurs.

There are 5 operations which can be exectued on the list of get parameters:

The default behaviour is to leave the query string unmodified.

Clear

The first operation is the basic clearing of the whole query string in order to have a fresh start. Any operation executed before that one will be without effect.

Add

You can choose to add any get parameter to the URL. If the parameter already exists, it will be twice in the query string, which may create unexpected behaviour on the other side of the redirection.

The new parameter's value can be:

  • a constant string your giving to the operation
  • the path of the query (before rewritting)
  • the domain name of the query (before rewritting)

Parameters:

  • name: the name of the paramter you will create
  • value: the value of the parameter (a string, :path or :domain)

Delete

Of course, if you can add, you can delete.

Parameter:

  • name: the name of the parameter to delete

Update (the value)

The value update is performed by applying a regular expression substitution to the value of the parameter.

Parameters:

  • name: the name of the parameter to update
  • match: the regular expression used to match the old value
  • replacement: the replacement string used to defini the new value

Rename

Often, it's easier to rename a parameter than delete and re-create it.

Parameters:

  • name: the old name of the parameter
  • new-name: the new name of the parameter

Management

Management options can be setup when creating the server.

Currently two management options are supported:

  • admin-host: The domain name used to manage the server (default is "management.invalid").
  • admin-allowed: A list of CIDR blocks. IP addresses in these blocks are allowed to manage the server (default is localhost only)

Each CIDR network specifications is a pair of two elements. The first one is an IPv4 address (either a string in dotted notation "127.0.0.1" or a vector of four integers in host order #(127 0 0 1)). The second is the prefix-length of the CIDR block. If the second part is missing, its default value is 32.

The recommended tool to manage Cheshire is curl or another low level HTTP or TCP tool such as nc(1) or telnet(1).

The management API is splited in three parts:

  1. Global management
  2. Domain rules management
  3. URI rules management

Each operation is specified using three mecanisms:

  1. The URI of the operation (to choose what you want to do).
  2. The GET parameters (URL query string) to select the rule you want to manage.
  3. The POST parameters to provide the information required by the operation you want to perform.

Global management

Global management operations are impacting the behavior of the whole server.

Save the current rules

Path: /save-rules

POST Parameter:

  • name (optional): name of the file in which the rules will be stored. If the parameter is not provided, the file used is the one from which the rules have been pre-loaded (rules-file).

The file will be stored in the directory specified as the rules-directory configuration and with the crr extension. If there is no such configuration, the directory of the rules-file configuration will be used.

Example:

` POST /save-rules HTTP/1.1 Host: management.invalid Content-type: application/x-www-form-urlencoded

name=my-bkp `

Load a new set of rules

Path: /load-rules

POST Parameter:

  • name (optional): name of the file from which the rules will be loaded. If the parameter is not provided, the file used is the one from which the rules have been pre-loaded (rules-file).
  • erase-all: If this parameter is not given, an error message will be sent. Since loading a new set of rules delete any other rule currently in effect, this confirmation is here as a security.

The file will be loaded from the directory specified as the rules-directory configuration and with the crr extension. If there is no such configuration, the directory of the rules-file configuration will be used.

Example:

` POST /load-rules HTTP/1.1 Host: management.invalid Content-type: application/x-www-form-urlencoded

name=my-bkp erase-all=OK `

Domain name rule management

The domain rule management operations are in the "folder" /domain-name-rule/. For each of the following rule, the path will therefore be prefixed by /domain-name-rule.

List domain name rules

Path: /list

GET parameters (all optionals):

  • kind: The kind of the domain rule key (should be one of exact, suffix or regex.
  • match: A regular expression applied on the domain rule match specification.
  • replacement: A regular expression applied on the domain rule replacement specification.

Returns the list of domain names rules matching the parameters. If a criteria is omitted all rules will match this criteria.

Example:

GET /domain-name-rule/list?kind=exact HTTP/1.1 Host: management.invalid

Add a domain name rule

Path: /add

POST parameters:

  • kind: The kind of match string. Must be one of "exact", "suffix" or "regex".
  • match: The match string used to check whether the rule matches the current URL.
  • replacement (optional): The replacement string used to modify the URL part matching the rule.
  • http-code (optional): The HTTP Status code to be sent along for this redirection.
  • position (optional): Position at which the rule will be inserted in the rule list. If none is provided, the rule is inserted at the beginning of the list.
  • protocol (optional): Protocol to use after the redirection. Must be one of http or https.
  • port (optional): Port number to use after the redirection.

Example:

` POST /domain-name-rule/add HTTP/1.1 Host: management.invalid Content-type: application/x-www-form-urlencoded

kind=exact&match=www.domain.example&position=3 `

Remove a domain name rule

Path: /remove

GET parameters:

  • kind: The kind of the rule.
  • match: The match spec of the rule.

POST parameter:

  • confirmed: This parameter must be non-nil.

Example:

` POST /domain-name-rule/remove?kind=exact&match=www.domain.example HTTP/1.1 Host: management.invalid Content-type: application/x-www-form-urlencoded

confirmed=OK `

Update a domain name rule

Path: /update

GET parameters:

  • kind: The kind of the rule.
  • match: The match spec of the rule.

POST parameters (all optional):

  • new-kind: The new kind to use for the rule from now on.
  • new-match: The new match spec to use for the rule from now on.
  • new-replacement: The new replacement to use for the rule from now on.
  • new-http-code: The new HTTP Status code to be used for this rule redirection from now on.

Update the query string operations

The query string operations management is in the "folder" /query-string-updates/. See Query string operation management for the details.

When applied to domain name rule, all these operations have two common GET parameters:

  • domain-name-kind: The kind of the domain name rule.
  • domain-name-match: The match spec of the domain name rule.

URI rule management

The URI rule management operations are in the "folder" /uri-rule/. For each of the following rule, the path will therefore be prefixed by /uri-rule.

All this operations need to know on wich parent domain name rule they operate. Thus, each rule has two common GET parameters:

  • domain-name-kind: The kind of the domain name rule.
  • domain-name-match: The match spec of the domain name rule.

List URI rules

Path: /list

GET parameters (all optionals):

  • kind: The kind of the domain rule key (should be one of exact, prefix or regex.
  • match: A regular expression applied on the domain rule match specification.
  • replacement: A regular expression applied on the domain rule replacement specification.

Returns the list of URI rules matching the parameters. If a criteria is omitted all rules will match this criteria.

Example:

GET /uri-rule/list?domain-name-kind=exact&domain-name-match=www.domain.example&kind=exact HTTP/1.1 Host: management.invalid

Add a URI rule

Path: /add

POST parameters:

  • kind: The kind of match string. Must be one of "exact", "suffix" or "regex".
  • match: The match string used to check whether the rule matches the current URL.
  • replacement (optional): The replacement string used to modify the URL part matching the rule.
  • http-code (optional): The HTTP Status code to be sent along for this redirection.
  • position (optional): Position at which the rule will be inserted in the rule list. If none is provided, the rule is inserted at the beginning of the list.
  • protocol (optional): Protocol to use after the redirection. Must be one of http or https.
  • port (optional): Port number to use after the redirection.

Example:

` POST /uri-rule/add?domain-name-kind=exact&domain-name-match=www.domain.example HTTP/1.1 Host: management.invalid Content-type: application/x-www-form-urlencoded

kind=prefix&match=%2Ffoo&position=2 `

Remove a URI rule

Path: /remove

GET parameters:

  • kind: The kind of the rule.
  • match: The match spec of the rule.

POST parameter:

  • confirmed: This parameter must be non-nil.

Example:

` POST /uri-rule/remove?domain-name-kind=exact&domain-name-match=www.domain.example&kind=exact&match=www.domain.example HTTP/1.1 Host: management.invalid Content-type: application/x-www-form-urlencoded

confirmed=OK `

Update a URI rule

Path: /update

GET parameters:

  • kind: The kind of the rule.
  • match: The match spec of the rule.

POST parameters (all optional):

  • new-kind: The new kind to use for the rule from now on.
  • new-match: The new match spec to use for the rule from now on.
  • new-replacement: The new replacement to use for the rule from now on.
  • new-http-code: The new HTTP Status code to be used for this rule redirection from now on.

Update the query string operations

The query string operations management is in the "folder" /query-string-updates/. See Query string operation management for the details.

When applied to domain name rule, all these operations have two more common GET parameters:

  • uri-kind: The kind of the domain name rule.
  • uri-match: The match spec of the domain name rule.

Query string operations management

Query string management is currently very simple.

List query string operations

Path: /list

GET parameters (all optionals):

  • operation: The operation filter of the domain rule key (should be one of clear, add, delete, update or rename).
  • Any combination of name, new-name, match, replacement: a regex on the corresponding field.

Returns the list of query string operations matching the parameters. If a criteria is omitted all rules will match this criteria.

Example:

GET /domain-name-rule/query-string-updates/list?domain-name-kind=exact&domain-name-match=www.domain.example&operation=clear HTTP/1.1 Host: management.invalid

Add a query string operation

Path: /add

POST parameters:

  • operation: The operation filter of the domain rule key (should be one of clear, add, delete, update or rename).
  • Any combination of name, new-name, match, replacement which is valid for this operation.
  • position (optional): Position at which the operation will be inserted in the operation list. If none is provided, the operation is inserted at the beginning of the list.

When you create an add operation, you should provide one of the following parameters (they are mutually exclusive):

  • value: Its value is the value that will be given to the new GET parameter
  • path-as-value: If present, the path will be used as value for the new GET parameter
  • domain-as-value: If present, the domain name will be used as value for the new GET parameter

Example:

` POST /uri-rule/query-string-updates/add?domain-name-kind=exact&domain-name-match=www.domain.example&uri-name=%2Ffoobar%2F&uri-kind=prefix HTTP/1.1 Host: management.invalid Content-type: application/x-www-form-urlencoded

operation=add&name=redirect-from&domain-as-value=t `

Remove a query string operation

Path: /remove

GET parameters:

  • operation: The kind of the rule.
  • name: The name of the query parameter on which the operation is applied.
  • match: The match specification used in a query string update operation.

If name or match is not supported by the operation you want to delete, you must omit them.

POST parameter:

  • confirmed: This parameter must be non-nil.

Example:

` POST /uri-rule/query-string-updates/remove?domain-name-kind=exact&domain-name-match=www.domain.example&uri-name=%2Ffoobar%2F&uri-kind=prefix&operation=rename&name=domain-name-match HTTP/1.1 Host: management.invalid Content-type: application/x-www-form-urlencoded

confirmed=OK `

Data Storage

The data are stored in memory by a hierarchy of classes, check redirection-rule and subclasses.

Limitations

  • The implementation restricted part should be extracted away in another package/project (TODO).

  • Because of the inherent multiple domain names property of the project, Cheshire supports only HTTP, no HTTPS now or in the forseenable future is planned.

  • No offline rule management.

License

This software has been originally developed by Mathieu Lemoine <mlemoine@mentel.com> and is the sole property of Mentel Inc. (www.mentel.com). This software is distributed under the terms of the 3-clause BSD, stated as follow:

Copyright © 2012, Mathieu Lemoine <mlemoine@mentel.com>, Mentel Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of "Mentel Inc." nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FUNCTION

Public

PRELOAD-RULES (REDIRECTION-ACCEPTOR FILE)

This function restore the list of rules from file and set them as the list of rules for this acceptor. It's also registering the rule-file for future references.

Private

ABORT-REQUEST-HANDLER (&OPTIONAL RESULT)

This function can be called by a request handler at any time to immediately abort handling the request. This works as if the handler had returned RESULT. See the source code of REDIRECT for an example.

ADD-QS-UPDATE (RULE UPDATE &KEY POSITION)

This function add a new query string update operation to a redirection rule. <pre>position</pre> is the position at which the rule will be inserted in <pre>rules</pre>. If <pre>position</pre> is nil or unspecified, <pre>rule</pre> will be inserted at the begining of <pre>rules</pre>.

ADD-URI-RULE (DOMAIN-REDIRECTION-RULE URI-RULE &KEY POSITION)

This function adds <pre>rule</pre> (applying to URIs) to <pre>domain-redirection-rule</pre>. <pre>position</pre> is the position at which the rule will be inserted in <pre>rules</pre>. If <pre>position</pre> is nil or unspecified, <pre>rule</pre> will be inserted at the begining of <pre>rules</pre>.

ADMIN-DOMAIN-NAME-RULES-HANDLER% (PATH REDIRECTION-ACCEPTOR)

Handler for domain name rules management

ADMIN-HANDLER (REDIRECTION-ACCEPTOR)

Management handler.

ADMIN-QUERY-STRING-HANDLER% (PATH RULE)

Handler for query-string operation

ADMIN-URI-RULES-HANDLER% (PATH DOMAIN-NAME-RULE)

Handler for URI rules management.

APPLY-DEFAULT-DOMAIN-NAME-RULE (DOMAIN-NAME)

This function applies the default domain name redirection: if the domain-name does not start with a "www.",returns a permanent redirect to the same URL prepended with "www.", raise a rs-loop-detected condition otherwise.

APPLY-RULES (TARGET-STRING RULES)

This function looks through the list of rules to find a matching rule for <pre>target-string</pre>. The three returns values are: * Whether a rule was find or not, * The rewritten target string, * The matching rule. If no such rule is found, all three values are nil.

AUTHORIZATION (&OPTIONAL (REQUEST *REQUEST*))

Returns as two values the user and password (if any) as encoded in the 'AUTHORIZATION' header. Returns NIL if there is no such header.

CLASS<-QSU-OPERATION (OPERATION)

Returns the class corresponding to this query-string operation.

COMPOSE (FUNCTION &REST MORE-FUNCTIONS)

Returns a function composed of FUNCTION and MORE-FUNCTIONS that applies its arguments to to each in turn, starting from the rightmost of MORE-FUNCTIONS, and then calling the next one with the primary value of the last.

COMPUTE-REDIRECTION (RULES DOMAIN-NAME URI)

This function computes the actual value of the redirection for this domain-name and URI, following this set of rules. It return the list (new-domain-name new-uri . redirection-parameters)

COMPUTE-URI (PATH QUERY-STRING)

Append each parameter in the query string to the path. path is expected not to have any query-string.

CONTENT-LENGTH* (&OPTIONAL (REPLY *REPLY*))

The outgoing 'Content-Length' http header of REPLY.

SETFCONTENT-LENGTH* (NEW-VALUE &OPTIONAL (REPLY *REPLY*))

Sets the outgoing 'Content-Length' http header of REPLY.

CONTENT-TYPE* (&OPTIONAL (REPLY *REPLY*))

The outgoing 'Content-Type' http header of REPLY.

SETFCONTENT-TYPE* (NEW-VALUE &OPTIONAL (REPLY *REPLY*))

Sets the outgoing 'Content-Type' http header of REPLY.

CREATE-REGEX-MATCHER (REGEX REPLACEMENT)

This function creates the matcher for a rule based on a regex.

CURRY (FUNCTION &REST ARGUMENTS)

Returns a function that applies ARGUMENTS and the arguments it is called with to FUNCTION.

DRR-IS-LOOP-P (DRR &KEY ERROR-P)

Check if the domain name rule effect is empty, thus resulting in a loop.

EMPTYP (SEQUENCE)

Returns true if SEQUENCE is an empty sequence. Signals an error if SEQUENCE is not a sequence.

ENDS-WITH-SUBSEQ (SUFFIX SEQUENCE &KEY (TEST #'EQL))

Test whether SEQUENCE ends with SUFFIX. In other words: return true if the last (length SUFFIX) elements of SEQUENCE are equal to SUFFIX.

ENSURE-SYMBOL (NAME &OPTIONAL (PACKAGE *PACKAGE*))

Returns a symbol with name designated by NAME, accessible in package designated by PACKAGE. If symbol is not already accessible in PACKAGE, it is interned there. Returns a secondary value reflecting the status of the symbol in the package, which matches the secondary return value of INTERN. Example: (ensure-symbol :cons :cl) => cl:cons, :external

FILE-EXISTS-P (PATHSPEC)

Checks whether the file named by the pathname designator PATHSPEC exists and returns its truename if this is the case, NIL otherwise. The truename is returned in `canonical' form, i.e. the truename of a directory is returned as if by PATHNAME-AS-DIRECTORY.

FIND-DOMAIN-NAME-RULE (RULES KIND MATCH &KEY ERROR-P)

This function returns the domain name rule with matching <pre>kind</pre> and <pre>match</pre> in <pre>rules</pre> or nil if none was found. if <pre>error-p</pre> is true, an error of type <pre>rs-no-such-domain-rule</pre> is raised instead.

FIND-QS-UPDATE (RULE OPERATION NAME MATCH &KEY ERROR-P)

This function returns the query string update designated by operation name and match.

FIND-URI-RULE (DOMAIN-REDIRECTION-RULE KIND MATCH &KEY ERROR-P)

This function returns the URI rule with matching <pre>kind</pre> and <pre>match</pre> in <pre>domain-redirection-rule</pre> or nil if none was found. if <pre>error-p</pre> is true, an error of type <pre>rs-no-such-uri-rule</pre> is raised instead.

GET-PARAMETER (NAME &OPTIONAL (REQUEST *REQUEST*))

Returns the GET parameter with name NAME (a string) - or NIL if there is none. Search is case-sensitive.

GET-PARAMETERS* (&OPTIONAL (REQUEST *REQUEST*))

Returns an alist of the GET parameters associated with the REQUEST object REQUEST.

HEADER-IN* (NAME &OPTIONAL (REQUEST *REQUEST*))

Returns the incoming header with name NAME. NAME can be a keyword (recommended) or a string.

HOST (&OPTIONAL (REQUEST *REQUEST*))

Returns the 'Host' incoming http header value.

IP-CIDR-MATCH-P (IP1 IP2 &OPTIONAL (PREFIX-LENGTH 32))

Check if both IPs are in the same network with respect to this CIDR prefix-length. Each IPs can be either: * 32-bit positive integer (host order), * a four element integer list representing IPv4 address, i.e. #(127 0 0 1), * a string containing an IP addres in dotted notation. For example, to check A.B.C.D against a.b.c.d/n, this function could be invoked as (ip-cidr-match-p #(A B C D) #(a b c d) n).

ISO-TIME (&OPTIONAL (TIME (GET-UNIVERSAL-TIME)))

Returns the universal time TIME as a string in full ISO format.

LOAD-RULES (REDIRECTION-ACCEPTOR FILE)

Save all the rules in mentioned file.

MAKE-KEYWORD (NAME)

Interns the string designated by NAME in the KEYWORD package.

MAKE-QUERY-STRING-UPDATE (OPERATION &REST INITARGS)

Generic generation of a query string update. <pre>operation</pre> must be one of :clear, :add, :rename or :update and initargs is the list of initargs for the qs-{operation} class.

MERGE-REDIRECTION-PARAMETER (&REST LISTS)

This function merges a set parameters (return the last non-null one).

MERGE-REDIRECTION-PARAMETERS-LIST (RULES PARAMETER-READERS)

This function merges a list of parameters from a list of rules. For each element of parameter-readers, a parameter is extracted from each rule and the last one non-null is returned.

PARSE-CIDR-LIST (LIST)

Parse a comma-separated list of IPv4 CIDR specifications (such as "a.b.c.d/n, e.f.g.h/m"). The CIDR prefix may be omited. Return a list of CIDR specification, each being of the form (IP prefix-length).

PARSE-INTEGER-OR-NIL (STRING &REST KEYS)

Just like parse-integer, but if string is nil, returns (values nil nil) instead of throwing an error.

POST-PARAMETER (NAME &OPTIONAL (REQUEST *REQUEST*))

Returns the POST parameter with name NAME (a string) - or NIL if there is none. Search is case-sensitive.

POST-PARAMETERS* (&OPTIONAL (REQUEST *REQUEST*))

Returns an alist of the POST parameters associated with the REQUEST object REQUEST.

QSU-OPERATION<-CLASS (CLASS)

Returns the query-string operation corresponding to this class.

QUERY-STRING* (&OPTIONAL (REQUEST *REQUEST*))

Returns the query string of the REQUEST object REQUEST. That's the part behind the question mark (i.e. the GET parameters).

REDIRECT (TARGET &KEY (HOST (HOST *REQUEST*) HOST-PROVIDED-P) PORT (PROTOCOL (IF (SSL-P) HTTPS HTTP)) (ADD-SESSION-ID (NOT (OR HOST-PROVIDED-P (STARTS-WITH-SCHEME-P TARGET) (COOKIE-IN (SESSION-COOKIE-NAME *ACCEPTOR*))))) (CODE +HTTP-MOVED-TEMPORARILY+))

Redirects the browser to TARGET which should be a string. If TARGET is a full URL starting with a scheme, HOST, PORT and PROTOCOL are ignored. Otherwise, TARGET should denote the path part of a URL, PROTOCOL must be one of the keywords :HTTP or :HTTPS, and the URL to redirect to will be constructed from HOST, PORT, PROTOCOL, and TARGET. Adds a session ID if ADD-SESSION-ID is true. If CODE is a 3xx redirection code, it will be sent as status code.

REDIRECTION-RULE= (RULE1 RULE2 &REST RULES)

This function checks whether two redirection rules are equals.

REFERER (&OPTIONAL (REQUEST *REQUEST*))

Returns the 'Referer' (sic!) http header.

REGEX-REPLACE (REGEX TARGET-STRING REPLACEMENT &KEY (START 0) (END (LENGTH TARGET-STRING)) PRESERVE-CASE SIMPLE-CALLS (ELEMENT-TYPE 'CHARACTER))

Try to match TARGET-STRING between START and END against REGEX and replace the first match with REPLACEMENT. Two values are returned; the modified string, and T if REGEX matched or NIL otherwise. REPLACEMENT can be a string which may contain the special substrings "\&" for the whole match, "\`" for the part of TARGET-STRING before the match, "\'" for the part of TARGET-STRING after the match, "\N" or "\{N}" for the Nth register where N is a positive integer. REPLACEMENT can also be a function designator in which case the match will be replaced with the result of calling the function designated by REPLACEMENT with the arguments TARGET-STRING, START, END, MATCH-START, MATCH-END, REG-STARTS, and REG-ENDS. (REG-STARTS and REG-ENDS are arrays holding the start and end positions of matched registers or NIL - the meaning of the other arguments should be obvious.) Finally, REPLACEMENT can be a list where each element is a string, one of the symbols :MATCH, :BEFORE-MATCH, or :AFTER-MATCH - corresponding to "\&", "\`", and "\'" above -, an integer N - representing register (1+ N) -, or a function designator. If PRESERVE-CASE is true, the replacement will try to preserve the case (all upper case, all lower case, or capitalized) of the match. The result will always be a fresh string, even if REGEX doesn't match. ELEMENT-TYPE is the element type of the resulting string.

REMOTE-ADDR* (&OPTIONAL (REQUEST *REQUEST*))

Returns the address the current request originated from.

REMOVE-QS-UPDATE (RULE OPERATION NAME MATCH)

This function removes the query string update designated by operation name and match.

REMOVE-URI-RULE (DOMAIN-REDIRECTION-RULE KIND MATCH)

This macro removes the rule from <pre>rule</pre> with matching <pre>kind</pre> and <pre>match</pre>. <pre>rule</pre> must match exactly. If no such rule is found, returns silently.

REQUEST-METHOD* (&OPTIONAL (REQUEST *REQUEST*))

Returns the request method as a Lisp keyword.

RESTORE-OBJECT (PLACE &OPTIONAL (BACKEND *CURRENT-BACKEND*))

Restore the object in PLACE using BACKEND

RETURN-CODE* (&OPTIONAL (REPLY *REPLY*))

The http return code of REPLY. The return codes Hunchentoot can handle are defined in specials.lisp.

SETFRETURN-CODE* (NEW-VALUE &OPTIONAL (REPLY *REPLY*))

Sets the http return code of REPLY.

RR-KEY (RULE)

This function returns the pair (kind match) for this rule.

RR-MATCHING-P (RULE TARGET-STRING)

This function checks whether a redirection rule is matching for this haystack.

SAVE-RULES (REDIRECTION-ACCEPTOR FILE)

Save all the rules in mentioned file.

SCRIPT-NAME* (&OPTIONAL (REQUEST *REQUEST*))

Returns the file name of the REQUEST object REQUEST. That's the requested URI without the query string (i.e the GET parameters).

SEND-BAD-REQUEST (MESSAGE &OPTIONAL (HTTP-CODE +HTTP-BAD-REQUEST+))

Error handling, abort the URL processing to signal an error to the client.

SERVER-PROTOCOL* (&OPTIONAL (REQUEST *REQUEST*))

Returns the request protocol as a Lisp keyword.

STARTS-WITH-SUBSEQ (PREFIX SEQUENCE &REST ARGS &KEY (RETURN-SUFFIX NIL) &ALLOW-OTHER-KEYS)

Test whether the first elements of SEQUENCE are the same (as per TEST) as the elements of PREFIX. If RETURN-SUFFIX is T the functions returns, as a second value, a displaced array pointing to the sequence after PREFIX.

STORE-OBJECT (OBJ STREAM &OPTIONAL (BACKEND *CURRENT-BACKEND*))

Store OBJ into STREAM. Not meant to be overridden, use backend-store-object instead

SYMBOLICATE (&REST THINGS)

Concatenate together the names of some strings and symbols, producing a symbol in the current package.

UNSUMMARIZE-QUERY-STRING-UPDATE% (SUMMARY)

Return the list of arguments to give to make-instance to recreate a similar query-string-update.

UPDATE-RULE% (RULE UPDATE-SPECS)

Updates a rule, each update spec should be ("new-{ATTRIBUTE}" . "{NEW-VALUE}").

URL-ENCODE (STRING &OPTIONAL (EXTERNAL-FORMAT *HUNCHENTOOT-DEFAULT-EXTERNAL-FORMAT*))

URL-encodes a string using the external format EXTERNAL-FORMAT. The default for EXTERNAL-FORMAT is the value of *HUNCHENTOOT-DEFAULT-EXTERNAL-FORMAT*.

USER-AGENT (&OPTIONAL (REQUEST *REQUEST*))

Returns the 'User-Agent' http header.

Undocumented

OUTPUT-TYPE-CODE (CODE STREAM)

REGISTER-CODE (CODE NAME &OPTIONAL (ERRORP NIL))

SETFRESTORE (NEW-VAL PLACE &OPTIONAL (BACKEND *DEFAULT-BACKEND*))

MACRO

Private

ADD-DOMAIN-NAME-RULE (RULES RULE &KEY POSITION)

This macro adds <pre>rule</pre> (applying to domaine names) in <pre>rules</pre>. <pre>position</pre> is the position at which the rule will be inserted in <pre>rules</pre>. If <pre>position</pre> is nil or unspecified, <pre>rule</pre> will be inserted at the begining of <pre>rules</pre>.

DEFINE-GENERIC-QSU-READER (NAME &OPTIONAL DEFAULT-VALUE)

Create a generic function and an associated method for query-string-update. This allow every reader to be used with any instance of query-string-update.

DELETEF (PLACE ITEM &REST REMOVE-KEYWORDS &ENVIRONMENT ENV)

Modify-macro for DELETE. Sets place designated by the first argument to the result of calling DELETE with ITEM, place, and the REMOVE-KEYWORDS.

IF-LET (BINDINGS &BODY (THEN-FORM &OPTIONAL ELSE-FORM))

Creates new variable bindings, and conditionally executes either THEN-FORM or ELSE-FORM. ELSE-FORM defaults to NIL. BINDINGS must be either single binding of the form: (variable initial-form) or a list of bindings of the form: ((variable-1 initial-form-1) (variable-2 initial-form-2) ... (variable-n initial-form-n)) All initial-forms are executed sequentially in the specified order. Then all the variables are bound to the corresponding values. If all variables were bound to true values, the THEN-FORM is executed with the bindings in effect, otherwise the ELSE-FORM is executed with the bindings in effect.

ONCE-ONLY (SPECS &BODY FORMS)

Evaluates FORMS with symbols specified in SPECS rebound to temporary variables, ensuring that each initform is evaluated only once. Each of SPECS must either be a symbol naming the variable to be rebound, or of the form: (symbol initform) Bare symbols in SPECS are equivalent to (symbol symbol) Example: (defmacro cons1 (x) (once-only (x) `(cons ,x ,x))) (let ((y 0)) (cons1 (incf y))) => (1 . 1)

REMOVE-DOMAIN-NAME-RULE (RULES KIND MATCH)

This macro removes the rule from <pre>rule</pre> with matching <pre>kind</pre> and <pre>match</pre>. <pre>rule</pre> must match exactly. If no such rule is found, returns silently.

WHEN-LET (BINDINGS &BODY FORMS)

Creates new variable bindings, and conditionally executes FORMS. BINDINGS must be either single binding of the form: (variable initial-form) or a list of bindings of the form: ((variable-1 initial-form-1) (variable-2 initial-form-2) ... (variable-n initial-form-n)) All initial-forms are executed sequentially in the specified order. Then all the variables are bound to the corresponding values. If all variables were bound to true values, then FORMS are executed as an implicit PROGN.

WITH-LOG-STREAM ((STREAM-VAR DESTINATION LOCK) &BODY BODY)

Helper macro to write log entries. STREAM-VAR is a symbol that will be bound to the logging stream during the execution of BODY. DESTINATION is the logging destination, which can be either a pathname designator of the log file, a symbol designating an open stream or NIL if no logging should be done. LOCK refers to the lock that should be held during the logging operation. If DESTINATION is a pathname, a flexi stream with UTF-8 encoding will be created and bound to STREAM-VAR. If an error occurs while writing to the log file, that error will be logged to *ERROR-OUTPUT*. Note that logging to a file involves opening and closing the log file for every logging operation, which is overall costly. Web servers with high throughput demands should make use of a specialized logging function rather than relying on Hunchentoot's default logging facility.

Undocumented

DEFRESTORE-CL-STORE ((TYPE PLACE &OPTIONAL QUALIFIER) &BODY BODY)

DEFSTORE-CL-STORE ((VAR TYPE STREAM &OPTIONAL QUALIFIER) &BODY BODY)

GENERIC-FUNCTION

Private

ACCEPTOR-DISPATCH-REQUEST (ACCEPTOR REQUEST)

This function is called to actually dispatch the request once the standard logging and error handling has been set up. ACCEPTOR subclasses implement methods for this function in order to perform their own request routing. If a method does not want to handle the request, it is supposed to invoke CALL-NEXT-METHOD so that the next ACCEPTOR in the inheritance chain gets a chance to handle the request.

ACCEPTOR-LOG-ACCESS (ACCEPTOR &KEY RETURN-CODE)

Function to call to log access to the acceptor. The RETURN-CODE, CONTENT and CONTENT-LENGTH keyword arguments contain additional information about the request to log. In addition, it can use the standard request accessor functions that are available to handler functions to find out more information about the request.

CREATE-SCANNER (REGEX &KEY CASE-INSENSITIVE-MODE MULTI-LINE-MODE SINGLE-LINE-MODE EXTENDED-MODE DESTRUCTIVE)

Accepts a regular expression - either as a parse-tree or as a string - and returns a scan closure which will scan strings for this regular expression and a list mapping registers to their names (NIL stands for unnamed ones). The "mode" keyboard arguments are equivalent to the imsx modifiers in Perl. If DESTRUCTIVE is not NIL, the function is allowed to destructively modify its first argument (but only if it's a parse tree).

EXECUTE-ACCEPTOR (TASKMASTER)

This is a callback called by the acceptor once it has performed all initial processing to start listening for incoming connections (see START-LISTENING). It usually calls the ACCEPT-CONNECTIONS method of the acceptor, but depending on the taskmaster instance the method might be called from a new thread.

QSU-KEY (UPDATE)

Return the information required to identify this update. Usually a list of the form (operation &optional name match)

QSU-SUMMARY (UPDATE)

This method converts the redirection rule to the alist ((:operation . operation) params)

RESOLVE-RR-MATCHER (RULE)

This function update the <pre>matcher</pre> slot of <pre>rule</pre> so <pre>rr-matching-p</pre> can be used. It is the only function allowed to modify the <pre>matcher</pre> slot

RESTORE (PLACE &OPTIONAL BACKEND)

Restore and object FROM PLACE using BACKEND. Not meant to be overridden, use backend-restore instead

RR-SUMMARY (RULE &KEY SERIALIZE)

This method converts the redirection rule to the list (kind match replacement . options)

SCAN (REGEX TARGET-STRING &KEY START END REAL-START-POS ((REAL-START-POS *REAL-START-POS*) NIL) (END (LENGTH TARGET-STRING)) (START 0))

Searches TARGET-STRING from START to END and tries to match REGEX. On success returns four values - the start of the match, the end of the match, and two arrays denoting the beginnings and ends of register matches. On failure returns NIL. REGEX can be a string which will be parsed according to Perl syntax, a parse tree, or a pre-compiled scanner created by CREATE-SCANNER. TARGET-STRING will be coerced to a simple string if it isn't one already. The REAL-START-POS parameter should be ignored - it exists only for internal purposes.

START (ACCEPTOR)

Starts the ACCEPTOR so that it begins accepting connections. Returns the acceptor.

START-LISTENING (ACCEPTOR)

Sets up a listen socket for the given ACCEPTOR and enables it to listen to incoming connections. This function is called from the thread that starts the acceptor initially and may return errors resulting from the listening operation (like 'address in use' or similar).

STORE (OBJ PLACE &OPTIONAL DESIGNATOR)

Store OBJ into Stream PLACE using backend BACKEND.

UPDATE-QUERY-STRING (UPDATE QUERY-STRING DOMAIN-NAME PATH)

This function (destructively) updates query-string to apply the specified query-string update. query-string is expected to be an alist of get parameters.

Undocumented

HOST-BYTE-ORDER (ADDRESS)

QSU-OPERATION (CONDITION)

URR-DOMAIN-NAME-RULE (CONDITION)

SETFURR-DOMAIN-NAME-RULE (NEW-VALUE CONDITION)

SLOT-ACCESSOR

Public

DRR-URI-RULES (OBJECT)

List of URI redirection rules for the domain names matching this redirection rule.

SETFDRR-URI-RULES (NEW-VALUE OBJECT)

List of URI redirection rules for the domain names matching this redirection rule.

Private

ACCEPTOR-ACCESS-LOG-DESTINATION (OBJECT)

Destination of the access log which contains one log entry per request handled in a format similar to Apache's access.log. Can be set to a pathname or string designating the log file, to a open output stream or to NIL to suppress logging.

SETFACCEPTOR-ACCESS-LOG-DESTINATION (NEW-VALUE OBJECT)

Destination of the access log which contains one log entry per request handled in a format similar to Apache's access.log. Can be set to a pathname or string designating the log file, to a open output stream or to NIL to suppress logging.

ACCEPTOR-ERROR-TEMPLATE-DIRECTORY (OBJECT)

Directory pathname that contains error message template files for server-generated error messages. Files must be named <return-code>.html with <return-code> representing the HTTP return code that the file applies to, i.e. 404.html would be used as the content for a HTTP 404 Not found response.

SETFACCEPTOR-ERROR-TEMPLATE-DIRECTORY (NEW-VALUE OBJECT)

Directory pathname that contains error message template files for server-generated error messages. Files must be named <return-code>.html with <return-code> representing the HTTP return code that the file applies to, i.e. 404.html would be used as the content for a HTTP 404 Not found response.

ACCEPTOR-SHUTDOWN-P (OBJECT)

A flag that makes the acceptor shutdown itself when set to something other than NIL.

SETFACCEPTOR-SHUTDOWN-P (NEW-VALUE OBJECT)

A flag that makes the acceptor shutdown itself when set to something other than NIL.

ACCEPTOR-TASKMASTER (OBJECT)

The taskmaster (i.e. an instance of a subclass of TASKMASTER) that is responsible for scheduling the work for this acceptor. The default depends on the MP capabilities of the underlying Lisp.

QSU-MATCH (UPDATE)

The Generic query string update reader for MATCH.

QSU-MATCHER (OBJECT)

Compiled regex matcher

QSU-NAME (UPDATE)

The Generic query string update reader for NAME.

QSU-NEW-NAME (UPDATE)

The Generic query string update reader for NEW-NAME.

QSU-REPLACEMENT (UPDATE)

The Generic query string update reader for REPLACEMENT.

QSU-VALUE (UPDATE)

The Generic query string update reader for VALUE.

REDIRECTION-ACCEPTOR-ADMIN-ALLOWED (OBJECT)

A list of CIDR block specifications. Each item of this list is a pair (IP prefix-length). IP is recommended to a string using the decimal dotted notation but could also be an host order 32 bytes integer or an host order byte vector.

SETFREDIRECTION-ACCEPTOR-ADMIN-ALLOWED (NEW-VALUE OBJECT)

A list of CIDR block specifications. Each item of this list is a pair (IP prefix-length). IP is recommended to a string using the decimal dotted notation but could also be an host order 32 bytes integer or an host order byte vector.

REDIRECTION-ACCEPTOR-ADMIN-HOST (OBJECT)

The domain name used to manage this redirection acceptor.

SETFREDIRECTION-ACCEPTOR-ADMIN-HOST (NEW-VALUE OBJECT)

The domain name used to manage this redirection acceptor.

REDIRECTION-ACCEPTOR-RULES (OBJECT)

The list of redirection rules used by this acceptor.

SETFREDIRECTION-ACCEPTOR-RULES (NEW-VALUE OBJECT)

The list of redirection rules used by this acceptor.

REDIRECTION-ACCEPTOR-RULES-DIRECTORY (OBJECT)

The directory in which rules will be stored. Only the default rule file can be out of this directory.

SETFREDIRECTION-ACCEPTOR-RULES-DIRECTORY (NEW-VALUE OBJECT)

Ensures the directory is a directory with no name and the crr type.

REDIRECTION-ACCEPTOR-RULES-FILE (OBJECT)

The default file used to store the rules. This is set when loading the rules from the file.

RETURN-CODE (OBJECT)

The http return code of this reply. The return codes Hunchentoot can handle are defined in specials.lisp.

SETFRETURN-CODE (NEW-VALUE OBJECT)

The http return code of this reply. The return codes Hunchentoot can handle are defined in specials.lisp.

RR-HTTP-CODE (OBJECT)

The HTTP Status Code sent when this rule is applied. Can be overwritten by a subsequent rule.

SETFRR-HTTP-CODE (NEW-VALUE OBJECT)

Ensures the type of the http-code slot.

RR-KIND (CONDITION)

A selector for the matching alogrithm used for this rule.

SETFRR-KIND (NEW-VALUE OBJECT)

Ensures that every modification of the <pre>kind</pre> slot is updating the <pre>matcher</pre> slot.

RR-MATCH (CONDITION)

The matching pattern used for this rule.

SETFRR-MATCH (NEW-VALUE OBJECT)

Ensures that every modification of the <pre>match</pre> slot is updating the <pre>matcher</pre> slot.

RR-MATCHER (OBJECT)

The matching closure implementing this rule matching algorithm and performing the replacement.

RR-PORT (OBJECT)

Port to use for the redirection. Default depends on the protocol

SETFRR-PORT (NEW-VALUE OBJECT)

Port to use for the redirection. Default depends on the protocol

RR-PROTOCOL (OBJECT)

The protocol to use after redirection (HTTP or HTTPS)

SETFRR-PROTOCOL (NEW-VALUE OBJECT)

The protocol to use after redirection (HTTP or HTTPS)

RR-QS-UPDATES (OBJECT)

List of query string update performed when this rule match.

SETFRR-QS-UPDATES (NEW-VALUE OBJECT)

List of query string update performed when this rule match.

RR-REPLACEMENT (OBJECT)

The replacement specification for this string. If it's null, this rule does not modify its target-string.

SETFRR-REPLACEMENT (NEW-VALUE OBJECT)

Ensures that every modification of the <pre>replacement</pre> slot is updating the <pre>matcher</pre> slot.

TASKMASTER-ACCEPTOR (OBJECT)

A backpointer to the acceptor instance this taskmaster works for.

SETFTASKMASTER-ACCEPTOR (NEW-VALUE OBJECT)

A backpointer to the acceptor instance this taskmaster works for.

VARIABLE

Private

*ACCESS-LOG-LOCK*

A global lock to prevent concurrent access to the log file used by the ACCEPTOR-LOG-ACCESS function.

*QSU-GENERIC-READERS*

List of query string update generic readers

+DEFAULT-DOMAIN-NAME-RULE+

Domain name rule with default behaviour. This should be treated as a constant, If the object, value or binding is modified behaviour is undefined.

+DOMAIN-REDIRECTION-RULE-CODE+

cl-store type-code for domain name redirection rules.

+QSU-CODE+

cl-store type-code for query string updates.

+URI-REDIRECTION-RULE-CODE+

cl-store type-code for URI redirection rules.

Undocumented

*CHECK-FOR-CIRCS*

CLASS

Public

REDIRECTION-ACCEPTOR

Custom hunchentoot:acceptor implementing the behavior of the redirection server.

Private

ACCEPTOR

To create a Hunchentoot webserver, you make an instance of this class and use the generic function START to start it (and STOP to stop it). Use the :PORT initarg if you don't want to listen on the default http port 80. There are other initargs most of which you probably won't need very often. They are explained in detail in the docstrings of the slot definitions for this class. Unless you are in a Lisp without MP capabilities, you can have several active instances of ACCEPTOR (listening on different ports) at the same time.

DOMAIN-REDIRECTION-RULE

Class for redirection rules applied to domain names.

QS-ADD

Add a new parameter at the beginning the query string.

QS-CLEAR

Clear the query string. Since this class has no state nor parameters, it's a singleton.

QS-DELETE

Remove a parameter from the query string.

QS-RENAME

Rename the parameter in the query string.

QS-UPDATE

Use a regex to modify the value of a parameter in the query string.

QUERY-STRING-UPDATE

Root class for Query String operations.

REDIRECTION-RULE

Root class for redirection rules.

TWO-STEPS-START-ACCEPTOR

This acceptor implementation allow a two-step start: 1. the first step `start-listening` starts the socket without starting to accept connections 2. the second setp `start` starts to accept connection This system allow for example to daemonize the process and drop privileges before starting to accept connections.

URI-REDIRECTION-RULE

Class for redirection rules applied to URIs (path part of the URL, no query-string).

CONDITION

Private

RS-ERROR

Root condition for redirection server errors.

RS-LOOP-DETECTED

Error raised if a loop is detected by the redirection engine. If not caught, this loop will make the server reply with a "404 Not Found".

RS-NO-SUCH-DOMAIN-RULE

Error raised if a domain name rule cannot be found.

RS-NO-SUCH-QS-UPDATE

Error raised if a query string update cannot be found.

RS-NO-SUCH-RULE

Error raised if a rule cannot be found.

RS-NO-SUCH-URI-RULE

Error raised if an URI rule cannot be found.

CONSTANT

Private

+HTTP-BAD-REQUEST+

HTTP return code (400) for 'Bad Request'.

+HTTP-FORBIDDEN+

HTTP return code (403) for 'Forbidden'.

+HTTP-MOVED-PERMANENTLY+

HTTP return code (301) for 'Moved Permanently'.

+HTTP-NOT-FOUND+

HTTP return code (404) for 'Not Found'.