request.lsp
Module: Request
Author: Jeff Ober
Version: 1.1
Original location: http://static.artfulcode.net/newlisp/request.lsp
Source: request.lsp
Package definition: request.qwerty
Request module to replace input functions in the standard CGI module (updated for newlisp 10)
Request encapsulates the processing of CGI environmental variables in a different manner than the standard CGI library. POST and GET variables are separated, and the url is parsed into a list of segments in order to make use with .htaccess files and mod_rewrite simpler.
POST data can only be read once, after which it becomes unavailable to future parts of the program. Should the default cgi.lsp module precede this module, POST data will be unavailable through the Request class. If cgi.lsp is loaded after this module, POST data is unavailable to it.
This module does not include output functions, including setting cookies. Output is a function of the Response class.Version history
1.1 • fixed incompatibilites with newlisp 10
1.0 • initial release- § -
Request:method
syntax: (Request:method)
return: string
Returns the request method.
- § -
Request:get?
syntax: (Request:get?)
return: boolean
Predicates that the request method is GET.
- § -
Request:post?
syntax: (Request:post?)
return: boolean
Predicates that the request method is POST.
- § -
Request:get
syntax: (Request:get str-key)
parameter: str-key - a GET variable
Fetches a GET variable from the query string.
- § -
Request:post
syntax: (Request:post str-key)
parameter: str-key - a POST variable
Fetches a POST variable from the request content.
- § -
Request:cookies
syntax: (Request:cookies str-key)
parameter: str-key - a COOKIE variable
Fetches the value of a cookie.
- § -
Request:cookie?
syntax: (Request:cookie? str-key)
parameter: str-key - a COOKIE variable
Predicates that a COOKIE variable is set.
- § -
Request:segments
syntax: (Request:segments)
return: list
Returns a list of each part of the query path, e.g. /foo/bar/baz becomes ("foo" "bar" "baz").
- ∂ -
Artful Code
generated with newLISP and newLISPdoc