diff --git a/Rack/man/App-class.Rd.bak b/Rack/man/App-class.Rd.bak new file mode 100644 index 0000000..664171a --- /dev/null +++ b/Rack/man/App-class.Rd.bak @@ -0,0 +1,26 @@ +\name{App-class} +\Rdversion{1.1} +\docType{class} +\alias{App-class} +\alias{App} + +\title{Class \code{App}} +\description{ +Abstract class from which \code{Middleware} and \code{Builder} inherit. Provides the \code{app} field. + +\code{App} can also be used to instantiate reference classed applications wrapped around a function. See \code{\link{Middleware}} for an example. +} +\section{Fields}{ + \describe{ + \item{\code{app}:}{A Rack application.} + } +} +\section{Methods}{ + \describe{ + \item{\code{new(app=NULL)}:}{ Creates a new \code{App} object. \code{app} is any \code{Rack} aware R object.} + } +} +\seealso{ +\code{\link{is_rackable}}, \code{\link{Builder}}, and \code{\link{Middleware}}. +} +\keyword{classes} diff --git a/Rack/man/Brewery-class.Rd.bak b/Rack/man/Brewery-class.Rd.bak new file mode 100644 index 0000000..fe1ef8a --- /dev/null +++ b/Rack/man/Brewery-class.Rd.bak @@ -0,0 +1,44 @@ +\name{Brewery-class} +\Rdversion{1.1} +\docType{class} +\alias{Brewery-class} +\alias{Brewery} + +\title{Class \code{Brewery}} +\description{ +A \code{\link{Middleware}} class for mapping URLs to a directory of files that are subsequently passed to \code{\link{brew}}. When a file is brewed, the two variables \code{req} (an object of class \code{\link{Request}}) and \code{res} (an object of class \code{\link{Response}}) are available for use. + +} +\section{Methods}{ +\describe{ + \item{\code{new(url,root,...):}}{ + \code{url} is a character string or \code{\link{regexp}} on which to match, \code{root} is the name of the directory where brew files reside. Named arguments can be passed in via \code{...} and will be available within the scope of each brewed file. + } +}} + +\examples{ + +# +# This application runs any file found in tempdir() through brew. +# +s <- Rhttpd$new() +s$start(quiet=TRUE) +cat("

Random Number: <\%=rnorm(1)\%>

", + file=file.path(tempdir(),"index.html")) +s$add(name="random", + app=Builder$new( + Brewery$new(url="/",root=tempdir()), + Redirect$new("/index.html") + ) +) +\dontrun{ +s$browse('random') # Opens a browser window to the app. +} +file.remove(file.path(tempdir(),"index.html")) +rm(s) +} + +\seealso{ +\code{\link{Rhttpd}}, \code{\link{Builder}}, \code{\link{Redirect}}, and \code{\link{brew}}. +} +\keyword{classes} diff --git a/Rack/man/Builder-class.Rd.bak b/Rack/man/Builder-class.Rd.bak new file mode 100644 index 0000000..8d53b14 --- /dev/null +++ b/Rack/man/Builder-class.Rd.bak @@ -0,0 +1,49 @@ +\name{Builder-class} +\Rdversion{1.1} +\docType{class} +\alias{Builder-class} +\alias{Builder} + +\title{Class \code{Builder}} +\description{ +A convenience object for combining various \code{Middleware} with a default application to create a more complex Rack application. +} +\examples{ + +# The following is the Hmisc example. Explore the folder +# system.file('exampleApps/Hmisc',package='Rack') for more information. +s <- Rhttpd$new() +\dontrun{ +library(Hmisc) +dir.create(file.path(tempdir(),'plots'),showWarnings=FALSE) +s$add( name="Hmisc", + app=Builder$new( + Static$new( + urls = c('/css','/images','/javascript'), + root = system.file('exampleApps/Hmisc',package='Rack') + ), + Static$new(urls='/plots',root=tempdir()), + Brewery$new( + url='/brew', + root= system.file('exampleApps/Hmisc',package='Rack'), + imagepath=file.path(tempdir(),'plots'), + imageurl='../plots/' + ), + Redirect$new('/brew/useR2007.rhtml') + ) +) +s$start(quiet=TRUE) +s$browse('Hmisc') # Opens a browser window to the application. +} +s$remove(all=TRUE) +s$stop() +} +\seealso{ +\code{\link{Rhttpd}}, \code{\link{Static}}, \code{\link{Brewery}}, and \code{\link{Redirect}}. +} +\keyword{classes} +\section{Methods}{ + \describe{ + \item{\code{new(...)}:}{ Arguments can be any \code{Middleware} object while the last argument in the list must be a valid \code{Rack} application. That is, it will handle the incoming request without deferring to another application. } + } +} diff --git a/Rack/man/File-class.Rd b/Rack/man/File-class.Rd index 8194326..fb1cb4c 100644 --- a/Rack/man/File-class.Rd +++ b/Rack/man/File-class.Rd @@ -12,7 +12,7 @@ A Rack application that serves static files from a root directory, according to # This example serves all your files in /etc (on UNIX and Mac only). # # Note that when you open the application, you will see the word -# 'Forbidden'. "File" doesn's serve directories, so you must amend the +# 'Forbidden'. "File" doesn't serve directories, so you must amend the # url in the location bar with the file you want to view. Try adding /passwd. s <- Rhttpd$new() diff --git a/Rack/man/File-class.Rd.bak b/Rack/man/File-class.Rd.bak new file mode 100644 index 0000000..8194326 --- /dev/null +++ b/Rack/man/File-class.Rd.bak @@ -0,0 +1,36 @@ +\name{File-class} +\Rdversion{1.1} +\docType{class} +\alias{File-class} +\alias{File} + +\title{Class \code{File}} +\description{ +A Rack application that serves static files from a root directory, according to the path info of the Rack request. +} +\examples{ +# This example serves all your files in /etc (on UNIX and Mac only). +# +# Note that when you open the application, you will see the word +# 'Forbidden'. "File" doesn's serve directories, so you must amend the +# url in the location bar with the file you want to view. Try adding /passwd. + +s <- Rhttpd$new() +s$start(quiet=TRUE) +s$add(name="etc",app=File$new('/etc')) +\dontrun{ +s$browse('etc') # Opens a browser window to the app. +} +s$remove(all=TRUE) +rm(s) +} +\section{Methods}{ +\describe{ + \item{\code{new(root):}}{ + \code{root} is the name of the directory from where to serve files. + } +}} +\seealso{ +\code{\link{Rhttpd}}. +} +\keyword{classes} diff --git a/Rack/man/Middleware-class.Rd.bak b/Rack/man/Middleware-class.Rd.bak new file mode 100644 index 0000000..af5b94c --- /dev/null +++ b/Rack/man/Middleware-class.Rd.bak @@ -0,0 +1,61 @@ +\name{Middleware-class} +\Rdversion{1.1} +\docType{class} +\alias{Middleware-class} +\alias{Middleware} + +\title{Class \code{Middleware}} +\description{ +An abstract class for building Rack Middleware applications. \code{Middleware} applications either handle the incoming web request or hand off the request to the Rack app defined in the field of the same name. +} +\examples{ +# Middleware applications are typically instantiated in the argument list of +# Builder$new(), but here is stand-alone example. +# +# Once your browser loads the app, you will see something like this in +# your location bar: http://127.0.0.1:28649/custom/middle. Add '/foo' +# onto the end of that and reload. + +setRefClass( + 'FooBar', + contains = 'Middleware', + methods = list( + initialize = function(...){ + # app to defer to. + callSuper(app=App$new(function(env){ + res <- Response$new() + res$write("

I'm the deferred app.

") + res$finish() + })) + }, + call = function(env){ + req <- Request$new(env) + res <- Response$new() + if (length(grep('foo',req$path_info()))){ + res$write("

I'm the middleware app.

") + return(res$finish()) + } else { + app$call(env) + } + } + ) +) +s <- Rhttpd$new() +s$start(quiet=TRUE) +s$add(name="middle",app=getRefClass('FooBar')$new()) +\dontrun{ +s$browse('middle') # Opens a browser window to the app. +} +s$remove(all=TRUE) +rm(s) +} +\seealso{ +The following classes implement Middleware: + \code{\link{Brewery}} and \code{\link{Static}}. +} +\section{Methods}{ + \describe{ + \item{\code{set_app(app)}:}{ \code{app} is a \code{\link{Rack}} application that will handle the request if this Middleware app does not. } + } +} +\keyword{classes} diff --git a/Rack/man/Mime-class.Rd b/Rack/man/Mime-class.Rd index ef2c32a..9187407 100644 --- a/Rack/man/Mime-class.Rd +++ b/Rack/man/Mime-class.Rd @@ -15,7 +15,7 @@ Mime$mime_type('.png') \keyword{classes} \section{Methods}{ \describe{ - \item{\code{file_extname(fname=NULL)}:}{ Returns the file extentions for the given file.} - \item{\code{mime_type(ext=NULL, fallback='application/octet-stream')}:}{ Returns the MIME type given the file extension. Besure to include the dot character in \code{ext}. If no match is found, then the fallback MIME type is returned.} + \item{\code{file_extname(fname=NULL)}:}{ Returns the file extensions for the given file.} + \item{\code{mime_type(ext=NULL, fallback='application/octet-stream')}:}{ Returns the MIME type given the file extension. Be sure to include the dot character in \code{ext}. If no match is found, then the fallback MIME type is returned.} } } diff --git a/Rack/man/Mime-class.Rd.bak b/Rack/man/Mime-class.Rd.bak new file mode 100644 index 0000000..ef2c32a --- /dev/null +++ b/Rack/man/Mime-class.Rd.bak @@ -0,0 +1,21 @@ +\name{Mime-class} +\Rdversion{1.1} +\docType{class} +\alias{Mime-class} +\alias{Mime} + +\title{Class \code{Mime} and object \code{Mime}} +\description{ +A convenience object for determining the MIME type of a file name. +} +\examples{ +Mime$file_extname('foo.png') +Mime$mime_type('.png') +} +\keyword{classes} +\section{Methods}{ + \describe{ + \item{\code{file_extname(fname=NULL)}:}{ Returns the file extentions for the given file.} + \item{\code{mime_type(ext=NULL, fallback='application/octet-stream')}:}{ Returns the MIME type given the file extension. Besure to include the dot character in \code{ext}. If no match is found, then the fallback MIME type is returned.} + } +} diff --git a/Rack/man/Multipart-class.Rd.bak b/Rack/man/Multipart-class.Rd.bak new file mode 100644 index 0000000..df2df9a --- /dev/null +++ b/Rack/man/Multipart-class.Rd.bak @@ -0,0 +1,43 @@ +\name{Multipart-class} +\Rdversion{1.1} +\docType{class} +\alias{Multipart-class} +\alias{Multipart} + +\title{Class \code{Multipart} and object \code{Multipart}} +\description{ +A convenience object for parsing multipart/form-data POST payloads. +} +\examples{ +s <- Rhttpd$new() +s$start(quiet=TRUE) +s$add(name="multi", + app=function(env){ + req <- Request$new(env) + res <- Response$new() + res$write('
') + res$write('Upload a file: ') + res$write('

') + post <- Multipart$parse(env) + if (length(post)){ + poststr <- paste(capture.output(str(post),file=NULL),collapse='\n') + res$write(c('
',poststr,'
')) + } + res$finish() + } +) +\dontrun{ +s$browse('multi') # Opens a browser window to the app. +} +s$remove(all=TRUE) +rm(s) +} +\seealso{ +\code{\link{Rhttpd}}, \code{\link{Request}}, and \code{\link{Response}}. +} +\section{Methods}{ + \describe{ + \item{\code{parse(env)}:}{ Returns parsed POST payload as a named list. \code{env} is an environment created by \code{Rhttpd} and conforms to the \code{\link{Rack}} specification.} + } +} +\keyword{classes} diff --git a/Rack/man/Rack-package.Rd b/Rack/man/Rack-package.Rd index 712c5d7..65b46a6 100644 --- a/Rack/man/Rack-package.Rd +++ b/Rack/man/Rack-package.Rd @@ -39,7 +39,7 @@ function(env){ } } -And the equivalent referenc class example: +And the equivalent reference class example: \preformatted{ setRefClass('HelloWorld', @@ -93,7 +93,7 @@ variables: or absence of the appropriate HTTP header in the request.} } -In addtion, the environment must include the following Rack-specific variables: +In addition, the environment must include the following Rack-specific variables: \describe{ \item{rack.version}{ This version of Rack.} diff --git a/Rack/man/Rack-package.Rd.bak b/Rack/man/Rack-package.Rd.bak new file mode 100644 index 0000000..712c5d7 --- /dev/null +++ b/Rack/man/Rack-package.Rd.bak @@ -0,0 +1,143 @@ +\name{Rack-package} +\alias{Rack-package} +\alias{Rack} +\docType{class} +\title{ +Rack: A web server interface and package for R +} +\description{ + This help page defines the Rack specification. It borrows heavily + from Ruby's Rack project: \url{http://rack.rubyforge.org/}. + + After reading this document, read the \code{\link{Rhttpd}} help file + as it will get you familiar with installing and running \code{Rack} + applications. Then explore the example applications located in: + + \code{system.file('exampleApps',package='Rack')}. +} + +\section{Rack applications}{ +A Rack application is an R reference class object that implements a 'call' +method or an R closure that takes exactly one argument, an environment, +and returns a list with three named elements: \code{'status'}, \code{'headers'}, +and \code{'body'}. +} +\section{Hello World}{ + +Here is a basic Rack application as a closure that implements 'hello world': + +\preformatted{ +function(env){ + body = paste('

Hello World! This is Rack',env$rack.version,'.

') + list( + status = 200L, + headers = list( + 'Content-Type' = 'text/html' + ), + body = body + ) +} +} + +And the equivalent referenc class example: + +\preformatted{ +setRefClass('HelloWorld', + methods = list( + call = function(env){ + list( + status = 200L, + headers = list( + 'Content-Type' = 'text/html' + ), + body = paste('

Hello World! This is Rack',env$rack.version,'.

') + ) + } + ) +) +} +} + +\section{The Environment}{ + +The environment argument is a true R environment object which the +application is free to modify. It is required to contain the following +variables: +\describe{ + \item{REQUEST_METHOD}{ The HTTP request method, such as "GET" or "POST". This + cannot ever be an empty string, and so is always required. } + + \item{SCRIPT_NAME}{ The initial portion of the request URL's "path" that + corresponds to the application object, so that the application knows + its virtual "location". This may be an empty string, if the application + corresponds to the "root" of the server.} + + \item{PATH_INFO}{ The remainder of the request URL's "path", designating the + virtual "location" of the request's target within the application. This + may be an empty string, if the request URL targets the application root + and does not have a trailing slash. This value may be percent-encoded + when I originating from a URL.} + + \item{QUERY_STRING}{ The portion of the request URL that follows the ?, + if any. May be empty, but is always required!} + +\item{SERVER_NAME, SERVER_PORT}{ When combined with SCRIPT_NAME and PATH_INFO, + these variables can be used to complete the URL. Note however that + HTTP_HOST, if present, should be used in preference to SERVER_NAME for + reconstructing the request URL. SERVER_NAME and SERVER_PORT can never + be empty strings, and so are always required.} + +\item{HTTP_ Variables}{ Variables corresponding to the client-supplied + HTTP request headers (i.e., variables whose names begin with HTTP_). The + presence or absence of these variables should correspond with the presence + or absence of the appropriate HTTP header in the request.} +} + +In addtion, the environment must include the following Rack-specific variables: + +\describe{ + \item{rack.version}{ This version of Rack.} + \item{rack.url_scheme}{'http' or 'https', depending on the request URL.} + \item{rack.input}{See \dQuote{The Input Stream} section.} + \item{rack.errors}{See \dQuote{The Error Stream} section.} +} +} +\section{The Input Stream}{ +The rack.input variable must contain an object created from a reference +class that implements \code{read_lines()}, \code{read()}, and \code{rewind()}: + +\describe{ + \item{\code{read_lines(l=-1L)}:}{takes one argument, the number of lines to read. Includes partial ending line.} + \item{\code{read(l=-1L)}:}{takes one argument, the number of bytes to read. Returns a raw vector.} + \item{\code{rewind()}:}{Rewinds the input stream back to the beginning.} +} +} + +\section{The Error Stream}{ +The rack.error variable must contain an object created from a reference +class that implements \code{flush()} and \code{cat()}: +\describe{ + \item{\code{flush()}:}{called with no arguments and makes the error stream immediately appear.} + \item{\code{cat(...,sep=" ",fill=FALSE,labels=NULL)}:}{called with the same arguments as R's \code{"\link{cat}"} without the \code{file} and append \code{argument}.} +} +} + +\section{The Response}{ + +Rack applications return a list with three named elements: \code{'status'}, \code{'headers'}, +and \code{'body'}. + +\subsection{\code{'status'}}{ +An HTTP status value as integer and must be greater than or equal to 100. +} + +\subsection{\code{'headers'}}{ +A named list that contains only character values corresponding to valid HTTP headers. +} +\subsection{\code{'body'}}{ +Either a character or raw vector. If the character vector is named +with value \code{'file'} then value of the vector is interpreted as the +location of a file. +}} +\author{ Jeffrey Horner } +\keyword{package} diff --git a/Rack/man/Request-class.Rd b/Rack/man/Request-class.Rd index 952cebd..6577462 100644 --- a/Rack/man/Request-class.Rd +++ b/Rack/man/Request-class.Rd @@ -107,8 +107,8 @@ rm(s) \item{\code{host()}:}{ Returns the server host as a character string. } \item{\code{POST()}:}{ Returns a named list containing the variables parsed from the POST payload.} \item{\code{trace()}:}{ Returns TRUE if the current request is 'TRACE'. } - \item{\code{script_name(s=NULL)}:}{ Returns the script name of the application, e.g. '/custom/multi'. Also, if \code{s} is not NULL, sets the script aname to \code{s}. } - \item{\code{content_type()}:}{ Returns the cotent-type header value as a character string. } + \item{\code{script_name(s=NULL)}:}{ Returns the script name of the application, e.g. '/custom/multi'. Also, if \code{s} is not NULL, sets the script name to \code{s}. } + \item{\code{content_type()}:}{ Returns the content-type header value as a character string. } \item{\code{delete()}:}{ Returns TRUE if the current request is 'DELETE'. } \item{\code{path_info(s=NULL)}:}{ Returns the portion of the url after the script name as a character string. If \code{s} is not NULL, sets the path info th \code{s}.} } diff --git a/Rack/man/Request-class.Rd.bak b/Rack/man/Request-class.Rd.bak new file mode 100644 index 0000000..952cebd --- /dev/null +++ b/Rack/man/Request-class.Rd.bak @@ -0,0 +1,119 @@ +\name{Request-class} +\Rdversion{1.1} +\docType{class} +\alias{Request-class} +\alias{Request} + +\title{Class \code{Request}} +\description{ +A convenience class for working with a \code{\link{Rack}} environment. Be sure to see the example at the end of this help file. +} +\examples{ +# +# The following example prints out the result of each method. +# +ls_str <- function(s) paste(capture.output(str(s),file=NULL),collapse='\n') +s <- Rhttpd$new() +s$start(quiet=TRUE) +s$add(name="request", + app=function(env){ + req <- Request$new(env) + res <- Response$new() + res$set_cookie('imacookie','42') + action <- req$to_url('/foo',bar=1,baz='three') + res$write('
') + res$write('Upload a file: ') + res$write('

')
+        res$write(c('parseable_data: ',req$parseable_data(),'\n'))
+        res$write(c('url: ',req$url(),'\n'))
+        res$write(c('request_method: ',req$request_method(),'\n'))
+        res$write(c('GET: ',ls_str(req$GET()),'\n'))
+        res$write(c('post: ',req$post(),'\n'))
+        res$write(c('media_type: ',req$media_type(),'\n'))
+        res$write(c('query_string: ',req$query_string(),'\n'))
+        res$write(c('fullpath: ',req$fullpath(),'\n'))
+        res$write(c('referer: ',req$referer(),'\n'))
+        res$write(c('cookies: ',ls_str(req$cookies()),'\n'))
+        res$write(c('content_charset: ',req$content_charset(),'\n'))
+        res$write(c('head: ',req$head(),'\n'))
+        res$write(c('accept_encoding: ',req$accept_encoding(),'\n'))
+        res$write(c('content_length: ',req$content_length(),'\n'))
+        res$write(c('form_data: ',req$form_data(),'\n'))
+        res$write(c('xhr: ',req$xhr(),'\n'))
+        res$write(c('params: ',ls_str(req$params()),'\n'))
+        res$write(c('media_type_params:\n',ls_str(req$media_type_params()),'\n'))
+        res$write(c('user_agent: ',req$user_agent(),'\n'))
+        res$write(c('put: ',req$put(),'\n'))
+        res$write(c('get: ',req$get(),'\n'))
+        res$write(c('path: ',req$path(),'\n'))
+        res$write(c('body: ',ls_str(req$body()),'\n'))
+        res$write(c('port: ',req$port(),'\n'))
+        res$write(c('host_with_port: ',req$host_with_port(),'\n'))
+        res$write(c('scheme: ',req$scheme(),'\n'))
+        res$write(c('ip: ',req$ip(),'\n'))
+        res$write(c('options: ',req$options(),'\n'))
+        res$write(c('to_url: ',req$to_url('foo',bar=1,baz='two'),'\n'))
+        res$write(c('host: ',req$host(),'\n'))
+        res$write(c('POST: ',ls_str(req$POST()),'\n'))
+        res$write(c('trace: ',req$trace(),'\n'))
+        res$write(c('script_name: ',req$script_name(),'\n'))
+        res$write(c('content_type: ',req$content_type(),'\n'))
+        res$write(c('delete: ',req$delete(),'\n'))
+        res$write(c('path_info: ',req$path_info(),'\n'))
+        res$write(c('\nRac env: ',ls_str(as.list(env)),'\n'))
+        res$finish()
+    }
+)
+\dontrun{
+s$browse('request') # Opens a browser window to the app.
+}
+s$remove(all=TRUE)
+rm(s)
+}
+\section{Methods}{
+  \describe{
+    \item{\code{parseable_data()}:}{ Returns a boolean value determining if the POST payload is parseable. }
+    \item{\code{url()}:}{ Returns url as a character string containing the scheme, host, port, and possibly the GET query string if supplied.}
+    \item{\code{request_method()}:}{ Returns the HTTP method as a character string, e.g. 'GET', 'POST', etc. }
+    \item{\code{GET()}:}{ Returns a named list containing the variables parsed from the query string. }
+    \item{\code{post()}:}{ Returns TRUE if the current request method is 'POST', FALSE otherwise. }
+    \item{\code{new(env)}:}{ Instantiates a new \code{Request} object for the given \code{Rack} environment.}
+    \item{\code{media_type()}:}{ Returns the media type for the current request as a character string.}
+    \item{\code{query_string()}:}{ Returns the unparsed query string. }
+    \item{\code{fullpath()}:}{ Returns the same string as url() but without the scheme, host, and port. }
+    \item{\code{referer()} or \code{referrer()}:}{ Returns the referring url.  }
+    \item{\code{cookies()}:}{ Returns any cookies in the request as a named list. }
+    \item{\code{content_charset()}:}{ Returns the content charset as a character string. }
+    \item{\code{head()}:}{ Returns TRUE if the HTTP method is 'HEAD', FALSE otherwise.}
+    \item{\code{accept_encoding()}:}{ Returns the accept encoding header as a character string.}
+    \item{\code{content_length()}:}{ Returns content length header value as a string. }
+    \item{\code{form_data()}:}{ Returns TRUE if there's form data, e.g. POST data with the request, FALSE otherwise.}
+    \item{\code{xhr()}:}{ Returns the x-requested-with header value as a character string.}
+    \item{\code{params()}:}{ Returns the combination of \code{POST()} and \code{GET()} in one named list.}
+    \item{\code{media_type_params()}:}{ Returns any media type parameters from the content type as a named list. }
+    \item{\code{user_agent()}:}{ Returns the user-agent header value as a character string. }
+    \item{\code{put()}:}{ Returns TRUE if the current request is a 'PUT'. }
+    \item{\code{get()}:}{ Returns TRUE if the current request is a 'GET'. }
+    \item{\code{path()}:}{ Returns a character string like \code{fullpath()} but without the query string. }
+    \item{\code{body()}:}{ Returns the 'rack.input' object from the environment. See \code{\link{RhttpdInputStream}} for more information.}
+    \item{\code{port()}:}{ Returns the server port as an integer.e}
+    \item{\code{host_with_port()}:}{ Returns the host and port as a character string separated by ':'. }
+    \item{\code{scheme()}:}{ Returns the scheme, e.g. 'http' or 'https', as a character string. }
+    \item{\code{ip()}:}{ Returns the remote IP address as a character string. }
+    \item{\code{options()}:}{ Returns TRUE if the current request is 'OPTIONS'. }
+    \item{\code{to_url(url, ...)}:}{ Concatenates the script name with the \code{url} argument along with any named parameters passed via \code{...} .}
+    \item{\code{host()}:}{ Returns the server host as a character string. }
+    \item{\code{POST()}:}{ Returns a named list containing the variables parsed from the POST payload.}
+    \item{\code{trace()}:}{ Returns TRUE if the current request is 'TRACE'. }
+    \item{\code{script_name(s=NULL)}:}{ Returns the script name of the application, e.g. '/custom/multi'. Also, if \code{s} is not NULL, sets the script aname to \code{s}. }
+    \item{\code{content_type()}:}{ Returns the cotent-type header value as a character string. }
+    \item{\code{delete()}:}{ Returns TRUE if the current request is 'DELETE'. }
+    \item{\code{path_info(s=NULL)}:}{ Returns the portion of the url after the script name as a character string. If \code{s} is not NULL, sets the path info th \code{s}.}
+  }
+}
+\seealso{
+\code{\link{Rhttpd}} and \code{\link{Response}}.
+}
+\keyword{classes}
diff --git a/Rack/man/Rhttpd-class.Rd b/Rack/man/Rhttpd-class.Rd
index 5bdf7c6..16ab794 100644
--- a/Rack/man/Rhttpd-class.Rd
+++ b/Rack/man/Rhttpd-class.Rd
@@ -26,7 +26,7 @@ install the application named \code{RackTestApp} located in:
 \code{system.file('exampleApps/RackTestApp.R',package='Rack')}.
 
 Also, see \code{\link{browseURL}} to learn how to get R to
-automatically launch your favorite web brwoser.
+automatically launch your favorite web browser.
 } 
 
 \seealso{
@@ -78,7 +78,7 @@ rm(s)
     \item{\code{full_url(i)}:}{ Returns the absolute url to the application for the given index.}
     \item{\code{start(listen='127.0.0.1', port=getOption('help.ports'), quiet=FALSE)}:}{ Starts the server on the given \code{listen} address and \code{port}. \code{listen} is always character string. Note that if there are no applications added to the object prior to starting, then the RackTestApp located in \code{system.file('exampleApps/RackTestApp.R',package='Rack')} is automatically added.}
     \item{\code{new()}:}{ Create a new \code{Rhttpd} object. }
-    \item{\code{launch(...)}:}{ Combines the steps of starting the server, creating an \code{RhttpdApp} object, adding it to the server, and openning the app in the browser. \code{...} arguement is passed to \code{RhttpdApp$new()}.}
+    \item{\code{launch(...)}:}{ Combines the steps of starting the server, creating an \code{RhttpdApp} object, adding it to the server, and opening the app in the browser. \code{...} argument is passed to \code{RhttpdApp$new()}.}
     \item{\code{debug()}:}{ Returns the integer value provided by \code{getOption('Rhttpd_debug')} or 0 if the option is NULL. }
     \item{\code{stop()}:}{ Stops the server. }
     \item{\code{add(app=NULL,name=NULL)}:}{ Adds a new \code{Rack} application to the server. \code{app} can be an \code{\link{RhttpdApp}} object or any \code{Rack} application. \code{name} is a character string and is ignored if \code{app} is an \code{RhttpdApp} object.}
diff --git a/Rack/man/Rhttpd-class.Rd.bak b/Rack/man/Rhttpd-class.Rd.bak
new file mode 100644
index 0000000..5bdf7c6
--- /dev/null
+++ b/Rack/man/Rhttpd-class.Rd.bak
@@ -0,0 +1,86 @@
+\name{Rhttpd-class}
+\Rdversion{1.1}
+\docType{class}
+\alias{Rhttpd-class}
+\alias{Rhttpd}
+
+\title{Class \code{Rhttpd}}
+\description{
+\code{Rhttpd} is a convenience class for installing and running Rack
+applications. It hides the details of starting and stopping the server
+and adding and removing \code{Rack} applications from the server.
+
+Users starts by creating one \code{Rhttpd} object, then adding
+applications to it, and then starting the server (see the section
+\dQuote{Examples} for a typical session). There are no restrictions on
+creating more than one server object, but know that it only manages the
+applications that are added to it and not others.
+
+Applications can be added and removed regardless of whether or
+not the server is running.  Stopping the server does not remove
+any applications. Adding an application with the same name as
+one already installed simply overwrites the one installed. If
+the server is started with no applications installed, it will
+install the application named \code{RackTestApp} located in:
+
+\code{system.file('exampleApps/RackTestApp.R',package='Rack')}.
+
+Also, see \code{\link{browseURL}} to learn how to get R to
+automatically launch your favorite web brwoser.
+} 
+
+\seealso{
+\code{\link{RhttpdApp}} 
+}
+\examples{
+
+# Create an Rhttpd object and start the internal web server. Note that
+# if there are no applications added, then the default RackTest app in
+# system.file('exampleApps/RackTestApp.R',package='Rack') is automatically
+# added.
+
+s <- Rhttpd$new()
+s$start(quiet=TRUE)
+s$print()
+\dontrun{
+s$browse(1)
+}
+
+# Be sure to install the Hmisc package before installing and running
+# this application. You will want to; it's a pretty good one.
+# s$add(
+#    app=system.file('exampleApps/Hmisc/config.R',package='Rack'),
+#    name='hmisc')
+
+s$add(
+    app=system.file('exampleApps/helloworld.R',package='Rack'),
+    name='hello')
+s$add(
+    app=system.file('exampleApps/helloworldref.R',package='Rack'),
+    name='helloref')
+s$add(
+    app=system.file('exampleApps/summary.R',package='Rack'),
+    name='summary')
+
+s$print()
+
+#  Stops the server but doesn't uninstall the app
+s$stop()
+s$remove(all=TRUE)
+rm(s)
+}
+\keyword{classes}
+\section{Methods}{
+  \describe{
+    \item{\code{open(x)} or \code{browse(x)}:}{ Calls \code{\link{browseURL}} on the installed Rack application designated by \code{x}. \code{x} is either an integer or a character string. See the output of \code{print()}.}
+    \item{\code{print()} or \code{show()}:}{ Lists the installed Rack applications.}
+    \item{\code{remove(app,all=FALSE)}:}{ Removes the application known to the server. \code{app} can be an \code{RhttpdApp} object previously added, the name of the application as a character string, or an index as a numeric or integer value. See the output of \code{print()}.}
+    \item{\code{full_url(i)}:}{ Returns the absolute url to the application for the given index.}
+    \item{\code{start(listen='127.0.0.1', port=getOption('help.ports'), quiet=FALSE)}:}{ Starts the server on the given \code{listen} address and \code{port}. \code{listen} is always character string. Note that if there are no applications added to the object prior to starting, then the RackTestApp located in \code{system.file('exampleApps/RackTestApp.R',package='Rack')} is automatically added.}
+    \item{\code{new()}:}{ Create a new \code{Rhttpd} object. }
+    \item{\code{launch(...)}:}{ Combines the steps of starting the server, creating an \code{RhttpdApp} object, adding it to the server, and openning the app in the browser. \code{...} arguement is passed to \code{RhttpdApp$new()}.}
+    \item{\code{debug()}:}{ Returns the integer value provided by \code{getOption('Rhttpd_debug')} or 0 if the option is NULL. }
+    \item{\code{stop()}:}{ Stops the server. }
+    \item{\code{add(app=NULL,name=NULL)}:}{ Adds a new \code{Rack} application to the server. \code{app} can be an \code{\link{RhttpdApp}} object or any \code{Rack} application. \code{name} is a character string and is ignored if \code{app} is an \code{RhttpdApp} object.}
+  }
+}
diff --git a/Rack/man/RhttpdApp-class.Rd.bak b/Rack/man/RhttpdApp-class.Rd.bak
new file mode 100644
index 0000000..6f36808
--- /dev/null
+++ b/Rack/man/RhttpdApp-class.Rd.bak
@@ -0,0 +1,54 @@
+\name{RhttpdApp-class}
+\Rdversion{1.1}
+\docType{class}
+\alias{RhttpdApp-class}
+\alias{RhttpdApp}
+
+\title{Class \code{RhttpdApp}}
+\description{
+Creates a Rack application ready to add to an \code{\link{Rhttpd}} server.
+}
+\details{
+
+The internal web server allows dispatching to user-defined closures
+located in tools:::.httpd.handlers.env. For instance, if a handler named
+'foo' is placed there, then the url path to that handler is /custom/foo.
+
+\code{RhttpdApp} along with \code{\link{Rhttpd}} hide these details by
+allowing a user to create application objects specifying only their name
+and the application. There is currently a limit of 63 characters
+or less for application names.
+
+NOTE: When a file is given as the value of the \code{app} argument
+to \code{new()}, it is monitored for timestamp changes. If a change
+occurs in the modification time as returned by \code{\link{file.info}},
+then the file is sourced prior to handling subsequent requests.
+
+}
+\seealso{
+\code{\link{Rhttpd}}.
+}
+\examples{
+
+s <- Rhttpd$new()
+s$add(RhttpdApp$new(
+    name='summary',
+    app=system.file('exampleApps/summary.R',package='Rack')
+))
+s$start(quiet=TRUE)
+\dontrun{
+s$browse(1)
+}
+s$remove(all=TRUE)
+
+#  Stops the server but doesn't uninstall the app
+s$stop()
+
+rm(s)
+}
+\keyword{classes}
+\section{Methods}{
+  \describe{
+    \item{\code{new(app, name)}:}{ Creates an object of class \code{RhttpdApp}. Argument \code{app} can be any \code{\link{Rack}} aware object or it can be a location to a file whose source creates a Rack aware object. That object must be named either \code{'app'} or the value of \code{name}. \code{name} is a character vector.}
+  }
+}
diff --git a/Rack/man/RhttpdErrorStream-class.Rd.bak b/Rack/man/RhttpdErrorStream-class.Rd.bak
new file mode 100644
index 0000000..1f9272d
--- /dev/null
+++ b/Rack/man/RhttpdErrorStream-class.Rd.bak
@@ -0,0 +1,14 @@
+\name{RhttpdErrorStream-class}
+\Rdversion{1.1}
+\docType{class}
+\alias{RhttpdErrorStream-class}
+\alias{RhttpdErrorStream}
+
+\title{Class \code{RhttpdErrorStream}}
+\description{
+An internal class used by \code{\link{Rhttpd}}.
+}
+\examples{
+showClass("RhttpdErrorStream")
+}
+\keyword{classes}
diff --git a/Rack/man/URLMap-class.Rd.bak b/Rack/man/URLMap-class.Rd.bak
new file mode 100644
index 0000000..1e4c034
--- /dev/null
+++ b/Rack/man/URLMap-class.Rd.bak
@@ -0,0 +1,52 @@
+\name{URLMap-class}
+\Rdversion{1.1}
+\docType{class}
+\alias{URLMap-class}
+\alias{URLMap}
+
+\title{Class \code{URLMap}}
+\description{
+A \code{\link{Rack}} application that maps url paths to other \code{Rack} applications.
+}
+\seealso{ 
+\code{\link{Rhttpd}}.
+}
+\examples{
+s <- Rhttpd$new()
+s$add(
+    name="pingpong",
+    app=Rack::URLMap$new(
+        '/ping' = function(env){
+            req <- Rack::Request$new(env)
+            res <- Rack::Response$new()
+            res$write(sprintf('

Pong

',req$to_url("/pong"))) + res$finish() + }, + '/pong' = function(env){ + req <- Rack::Request$new(env) + res <- Rack::Response$new() + res$write(sprintf('

Ping

',req$to_url("/ping"))) + res$finish() + }, + '/?' = function(env){ + req <- Rack::Request$new(env) + res <- Rack::Response$new() + res$redirect(req$to_url('/pong')) + res$finish() + } + ) +) +s$start(quiet=TRUE) +\dontrun{ +s$browse('pingpong') +} +s$remove('pingpong') +s$stop() +rm(s) +} +\keyword{classes} +\section{Methods}{ + \describe{ + \item{\code{new(...)}:}{ Creates a \code{Rack} application. All arguments must be \code{Rack} applications and named as in the example.} + } +} diff --git a/Rack/man/Utils-class.Rd.bak b/Rack/man/Utils-class.Rd.bak new file mode 100644 index 0000000..366c892 --- /dev/null +++ b/Rack/man/Utils-class.Rd.bak @@ -0,0 +1,47 @@ +\name{Utils-class} +\Rdversion{1.1} +\docType{class} +\alias{Utils-class} +\alias{Utils} + +\title{Class \code{Utils}} +\description{ +A convenience object for working with various aspects of web requests and responses. +} +\seealso{ +\code{\link{Multipart}}. +} +\examples{ +Utils$bytesize('foo') +Utils$escape('foo bar') +Utils$unescape('foo+bar') +Utils$escape_html('foo ') +Utils$escape('foo ') +Utils$escape('foo\n') +Utils$status_code('OK') +Utils$status_code('Found') +Utils$status_code('Not Found') +x <- Utils$parse_query('foo=1&bar=baz') +x +Utils$rfc2822(Sys.time()) +Utils$timezero() +Utils$build_query(x) +rm(x) +} +\keyword{classes} +\section{Methods}{ + \describe{ + \item{\code{bytesize(string=NULL)}:}{ Returns size in bytes for \code{string}, a character vector. } + \item{\code{unescape(s=NULL)}:}{ returns the url decoded value of the character vector \code{s}.Also replaces the space character with \code{'+'}. } + \item{\code{status_code(status=NULL)}:}{ returns integer value for the given HTTP \code{status}, which can either be numeric or or a character vector describing the status. Returns \code{as.integer(500)} if \code{status} is NULL.} + \item{\code{escape_html(string=NULL)}:}{ replaces \code{"&"}, \code{"<"}, \code{">"}, \code{"'"}, and \code{'"'} with entity equivalents. } + \item{\code{raw.match(needle=NULL, haystack=NULL, all=TRUE)}:}{ returns index position of \code{needle} in \code{haystack}. All matched indexes are returned by default. \code{needle} is either a raw vector or character string. \code{haystack} is a raw vector.} + \item{\code{parse_query(qs=NULL, d=DEFAULT_SEP)}:}{ Creates a named list from the the query string \code{qs}. \code{d} is the separator value and defaults to \code{'[&;] *'}.} + \item{\code{rfc2822(ts=NULL)}:}{ Formats \code{ts} in RFC2822 time. \code{ts} must be a \code{\link{POSIXt}} object.} + \item{\code{escape(s=NULL)}:}{ Transforms any non-printable characters found in \code{s} to their percent-encoded equivalents.} + \item{\code{build_query(params=NULL)}:}{ Creates a query string from the named list given in \code{params}. } + \item{\code{timezero()}:}{ Returns a \code{POSIXct} object set to UNIX epoch. } + \item{\code{set_cookie_header(header, key, value, expires, path, domain, secure, httpOnly)}:}{ Sets an HTTP cookie header in the environment \code{header}. All arguments except \code{expires} are length 1 character vectors, while \code{expires} must be a \code{POSIXct} object. } + \item{\code{delete_cookie_header(header, key, value, expires, path, domain, secure, httpOnly)}:}{ Deletes the HTTP cookie header. } + } +} diff --git a/Rack/man/is_rackable.Rd b/Rack/man/is_rackable.Rd index 9bbd3a7..eb369b7 100644 --- a/Rack/man/is_rackable.Rd +++ b/Rack/man/is_rackable.Rd @@ -4,7 +4,7 @@ Test for Rackable applications } \description{ -A convenience function for testing whether or not objects are either a function or reference class as defined by the Rack specification for applicaions. +A convenience function for testing whether or not objects are either a function or reference class as defined by the Rack specification for applications. } \usage{ is_rackable(app) diff --git a/Rack/man/is_rackable.Rd.bak b/Rack/man/is_rackable.Rd.bak new file mode 100644 index 0000000..9bbd3a7 --- /dev/null +++ b/Rack/man/is_rackable.Rd.bak @@ -0,0 +1,21 @@ +\name{is_rackable} +\alias{is_rackable} +\title{ +Test for Rackable applications +} +\description{ +A convenience function for testing whether or not objects are either a function or reference class as defined by the Rack specification for applicaions. +} +\usage{ +is_rackable(app) +} +\arguments{ + \item{app}{ Any R object.} +} +\value{ + Logical determining whether or not argument is Rackable. Not vectorized. +} +\seealso{ +\code{\link{Rack}}. +} +\keyword{function} diff --git a/builds/Rack_1.0.zip b/builds/Rack_1.0.zip deleted file mode 100644 index bf6999b..0000000 Binary files a/builds/Rack_1.0.zip and /dev/null differ