ADDED modules/httpd/build/content.inc Index: modules/httpd/build/content.inc ================================================================== --- /dev/null +++ modules/httpd/build/content.inc @@ -0,0 +1,94 @@ +[section {Class ::httpd::content}] + +The httpd module includes several ready to use implementations of content mixins +for common use cases. Options are passed in to the [cmd add_uri] method of the server. + +[section {Class ::httpd::content.cgi}] + +An implementation to relay requests to process which will accept post data +streamed in vie stdin, and sent a reply streamed to stdout. + +[list_begin definitions] +[call method cgi_info] + +Mandatory method to be replaced by the end user. If needed, activates the +process to proxy, and then returns a list of three values: + +[arg exec] - The arguments to send to exec to fire off the responding process, minus the stdin/stdout redirection. + +[list_end] + +[section {Class ::httpd::content.file}] + +An implementation to deliver files from the local file system. + +[list_begin definitions] + +[call option [cmd path]] + +The root directory on the local file system to be exposed via http. + +[call option [cmd prefix]] + +The prefix of the URI portion to ignore when calculating relative file paths. +[list_end] + +[section {Class ::httpd::content.proxy}] + +An implementation to relay requests to another HTTP server, and relay +the results back across the request channel. + +[list_begin definitions] +[call method proxy_info] + +Mandatory method to be replaced by the end user. If needed, activates the +process to proxy, and then returns a list of three values: + +[arg proxyhost] - The hostname where the proxy is located + +[arg proxyport] - The port to connect to + +[arg proxyscript] - A pre-amble block of text to send prior to the mirrored request + +[list_end] + +[section {Class ::httpd::content.scgi}] + +An implementation to relay requests to a server listening on a socket +expecting SCGI encoded requests, and relay +the results back across the request channel. + +[list_begin definitions] +[call method scgi_info] + +Mandatory method to be replaced by the end user. If needed, activates the +process to proxy, and then returns a list of three values: + +[arg scgihost] - The hostname where the scgi listener is located + +[arg scgiport] - The port to connect to + +[arg scgiscript] - The contents of the [arg SCRIPT_NAME] header to be sent + +[list_end] + +[section {Class ::httpd::content.websocket}] + +A placeholder for a future implementation to manage requests that can expect to be +promoted to a Websocket. Currently it is an empty class. + +[section {SCGI Server Functions}] + +The HTTP module also provides an SCGI server implementation, as well as an HTTP +implementation. To use the SCGI functions, create an object of the [cmd http::server.scgi] +class instead of the [cmd http::server] class. + +[section {Class ::httpd::reply.scgi}] + +An modified [cmd http::reply] implementation that understands how to deal with +netstring encoded headers. + +[section {Class ::httpd::server.scgi}] + +A modified [cmd http::server] which is tailored to replying to request according to +the SCGI standard instead of the HTTP standard. DELETED modules/httpd/build/content.man Index: modules/httpd/build/content.man ================================================================== --- modules/httpd/build/content.man +++ /dev/null @@ -1,94 +0,0 @@ -[section {Class ::httpd::content}] - -The httpd module includes several ready to use implementations of content mixins -for common use cases. Options are passed in to the [cmd add_uri] method of the server. - -[section {Class ::httpd::content.cgi}] - -An implementation to relay requests to process which will accept post data -streamed in vie stdin, and sent a reply streamed to stdout. - -[list_begin definitions] -[call method cgi_info] - -Mandatory method to be replaced by the end user. If needed, activates the -process to proxy, and then returns a list of three values: - -[arg exec] - The arguments to send to exec to fire off the responding process, minus the stdin/stdout redirection. - -[list_end] - -[section {Class ::httpd::content.file}] - -An implementation to deliver files from the local file system. - -[list_begin definitions] - -[call option [cmd path]] - -The root directory on the local file system to be exposed via http. - -[call option [cmd prefix]] - -The prefix of the URI portion to ignore when calculating relative file paths. -[list_end] - -[section {Class ::httpd::content.proxy}] - -An implementation to relay requests to another HTTP server, and relay -the results back across the request channel. - -[list_begin definitions] -[call method proxy_info] - -Mandatory method to be replaced by the end user. If needed, activates the -process to proxy, and then returns a list of three values: - -[arg proxyhost] - The hostname where the proxy is located - -[arg proxyport] - The port to connect to - -[arg proxyscript] - A pre-amble block of text to send prior to the mirrored request - -[list_end] - -[section {Class ::httpd::content.scgi}] - -An implementation to relay requests to a server listening on a socket -expecting SCGI encoded requests, and relay -the results back across the request channel. - -[list_begin definitions] -[call method scgi_info] - -Mandatory method to be replaced by the end user. If needed, activates the -process to proxy, and then returns a list of three values: - -[arg scgihost] - The hostname where the scgi listener is located - -[arg scgiport] - The port to connect to - -[arg scgiscript] - The contents of the [arg SCRIPT_NAME] header to be sent - -[list_end] - -[section {Class ::httpd::content.websocket}] - -A placeholder for a future implementation to manage requests that can expect to be -promoted to a Websocket. Currently it is an empty class. - -[section {SCGI Server Functions}] - -The HTTP module also provides an SCGI server implementation, as well as an HTTP -implementation. To use the SCGI functions, create an object of the [cmd http::server.scgi] -class instead of the [cmd http::server] class. - -[section {Class ::httpd::reply.scgi}] - -An modified [cmd http::reply] implementation that understands how to deal with -netstring encoded headers. - -[section {Class ::httpd::server.scgi}] - -A modified [cmd http::server] which is tailored to replying to request according to -the SCGI standard instead of the HTTP standard. ADDED modules/httpd/build/reply.inc Index: modules/httpd/build/reply.inc ================================================================== --- /dev/null +++ modules/httpd/build/reply.inc @@ -0,0 +1,297 @@ +[section {Class ::httpd::reply}] + +A class which shephards a request through the process of generating a +reply. + +The socket associated with the reply is available at all times as the [arg chan] +variable. + +The process of generating a reply begins with an [cmd httpd::server] generating a +[cmd http::class] object, mixing in a set of behaviors and then invoking the reply +object's [cmd dispatch] method. + +In normal operations the [cmd dispatch] method: + +[list_begin enumerated] + +[enum] +Invokes the [cmd reset] method for the object to populate default headers. + +[enum] +Invokes the [cmd HttpHeaders] method to stream the MIME headers out of the socket + +[enum] +Invokes the [cmd {request parse}] method to convert the stream of MIME headers into a +dict that can be read via the [cmd request] method. + +[enum] +Stores the raw stream of MIME headers in the [arg rawrequest] variable of the object. + +[enum] +Invokes the [cmd content] method for the object, generating an call to the [cmd error] +method if an exception is raised. + +[enum] +Invokes the [cmd output] method for the object +[list_end] + +[para] + +[section {Reply Method Ensembles}] + +The [cmd http::reply] class and its derivatives maintain several variables as dictionaries +internally. Access to these dictionaries is managed through a dedicated ensemble. The +ensemble implements most of the same behaviors as the [cmd dict] command. + +Each ensemble implements the following methods above, beyond, or modifying standard dicts: + +[list_begin definitions] + +[call method [cmd ENSEMBLE::add] [arg field] [arg element]] + +Add [arg element] to a list stored in [arg field], but only if it is not already present om the list. + +[call method [cmd ENSEMBLE::dump]] + +Return the current contents of the data structure as a key/value list. + +[call method [cmd ENSEMBLE::get] [arg field]] + +Return the value of the field [arg field], or an empty string if it does not exist. + +[call method [cmd ENSEMBLE::reset]] + +Return a key/value list of the default contents for this data structure. + +[call method [cmd ENSEMBLE::remove] [arg field] [arg element]] + +Remove all instances of [arg element] from the list stored in [arg field]. + +[call method [cmd ENSEMBLE::replace] [arg keyvaluelist]] + +Replace the internal dict with the contents of [arg keyvaluelist] + +[call method [cmd ENSEMBLE::reset]] + +Replace the internal dict with the default state. + +[call method [cmd ENSEMBLE::set] [arg field] [arg value]] + +Set the value of [arg field] to [arg value]. + +[list_end] + +[section {Reply Method Ensemble: http_info}] + +Manages HTTP headers passed in by the server. + +Ensemble Methods: + +[list_begin definitions] + +[call method [cmd http_info::netstring]] + +Return the contents of this data structure as a netstring encoded block. + +[list_end] + +[section {Reply Method Ensemble: request}] + +Managed data from MIME headers of the request. + +[list_begin definitions] + +[call method [cmd request::parse] [arg string]] + +Replace the contents of the data structure with information encoded in a MIME +formatted block of text ([arg string]). + +[list_end] + +[section {Reply Method Ensemble: reply}] + +Manage the headers sent in the reply. + + +[list_begin definitions] + +[call method [cmd reply::output]] + +Return the contents of this data structure as a MIME encoded block appropriate +for an HTTP response. + +[list_end] + +[section {Reply Methods}] + +[list_begin definitions] +[call method [cmd close]] + +Terminate the transaction, and close the socket. + +[call method [cmd HttpHeaders] [arg sock] [arg ?debug?]] + +Stream MIME headers from the socket [arg sock], stopping at an empty line. Returns +the stream as a block of text. + +[call method [cmd dispatch] [arg newsock] [arg datastate]] + +Take over control of the socket [arg newsock], and store that as the [arg chan] variable +for the object. This method runs through all of the steps of reading HTTP headers, generating +content, and closing the connection. (See class writetup). + +[call method [cmd error] [arg code] [arg ?message?] [arg ?errorInfo?]] + +Generate an error message of the specified [arg code], and display the [arg message] as the +reason for the exception. [arg errorInfo] is passed in from calls, but how or if it should be +displayed is a prerogative of the developer. + +[call method [cmd content]] + +Generate the content for the reply. This method is intended to be replaced by the mixin. + +Developers have the option of streaming output to a buffer via the [cmd puts] method of the +reply, or simply populating the [arg reply_body] variable of the object. +The information returned by the [cmd content] method is not interpreted in any way. + +If an exception is thrown (via the [cmd error] command in Tcl, for example) the caller will +auto-generate a 500 {Internal Error} message. + +A typical implementation of [cmd content] look like: + +[example { + +tool::define ::test::content.file { + superclass ::httpd::content.file + # Return a file + # Note: this is using the content.file mixin which looks for the reply_file variable + # and will auto-compute the Content-Type + method content {} { + my reset + set doc_root [my http_info get doc_root] + my variable reply_file + set reply_file [file join $doc_root index.html] + } +} +tool::define ::test::content.time { + # return the current system time + method content {} { + my variable reply_body + my reply set Content-Type text/plain + set reply_body [clock seconds] + } +} +tool::define ::test::content.echo { + method content {} { + my variable reply_body + my reply set Content-Type [my request get CONTENT_TYPE] + set reply_body [my PostData [my request get CONTENT_LENGTH]] + } +} +tool::define ::test::content.form_handler { + method content {} { + set form [my FormData] + my reply set Content-Type {text/html; charset=UTF-8} + my puts [my html header {My Dynamic Page}] + my puts "" + my puts "You Sent

" + my puts "" + foreach {f v} $form { + my puts "" + } + my puts "
$f$v

" + my puts "Send some info:

" + my puts "

" + my puts "" + foreach field {name rank serial_number} { + set line "" + my puts $line + } + my puts "
$field
" + my puts [my html footer] + } +} + +}] + +[call method [cmd EncodeStatus] [arg status]] + +Formulate a standard HTTP status header from he string provided. + +[call method FormData] + +For GET requests, converts the QUERY_DATA header into a key/value list. + +For POST requests, reads the Post data and converts that information to +a key/value list for application/x-www-form-urlencoded posts. For multipart +posts, it composites all of the MIME headers of the post to a singular key/value +list, and provides MIME_* information as computed by the [cmd mime] package, including +the MIME_TOKEN, which can be fed back into the mime package to read out the contents. + +[call method MimeParse [arg mimetext]] + +Converts a block of mime encoded text to a key/value list. If an exception is encountered, +the method will generate its own call to the [cmd error] method, and immediately invoke +the [cmd output] method to produce an error code and close the connection. + +[call method [cmd DoOutput]] + +Generates the the HTTP reply, and streams that reply back across [arg chan]. + +[call method PostData [arg length]] + +Stream [arg length] bytes from the [arg chan] socket, but only of the request is a +POST or PUSH. Returns an empty string otherwise. + +[call method [cmd puts] [arg string]] + +Appends the value of [arg string] to the end of [arg reply_body], as well as a trailing newline +character. + +[call method [cmd reset]] + +Clear the contents of the [arg reply_body] variable, and reset all headers in the [cmd reply] +structure back to the defaults for this object. + +[call method [cmd timeOutCheck]] + +Called from the [cmd http::server] object which spawned this reply. Checks to see +if too much time has elapsed while waiting for data or generating a reply, and issues +a timeout error to the request if it has, as well as destroy the object and close the +[arg chan] socket. + +[call method [cmd timestamp]] + +Return the current system time in the format: [example {%a, %d %b %Y %T %Z}] + +[call method [cmd TransferComplete] [arg args]] + +Intended to be invoked from [cmd {chan copy}] as a callback. This closes every channel +fed to it on the command line, and then destroys the object. + +[example { + ### + # Output the body + ### + chan configure $sock -translation binary -blocking 0 -buffering full -buffersize 4096 + chan configure $chan -translation binary -blocking 0 -buffering full -buffersize 4096 + if {$length} { + ### + # Send any POST/PUT/etc content + ### + chan copy $sock $chan -size $SIZE -command [info coroutine] + yield + } + catch {close $sock} + chan flush $chan +}] + +[call method [cmd Url_Decode] [arg string]] + +De-httpizes a string. + +[list_end] DELETED modules/httpd/build/reply.man Index: modules/httpd/build/reply.man ================================================================== --- modules/httpd/build/reply.man +++ /dev/null @@ -1,297 +0,0 @@ -[section {Class ::httpd::reply}] - -A class which shephards a request through the process of generating a -reply. - -The socket associated with the reply is available at all times as the [arg chan] -variable. - -The process of generating a reply begins with an [cmd httpd::server] generating a -[cmd http::class] object, mixing in a set of behaviors and then invoking the reply -object's [cmd dispatch] method. - -In normal operations the [cmd dispatch] method: - -[list_begin enumerated] - -[enum] -Invokes the [cmd reset] method for the object to populate default headers. - -[enum] -Invokes the [cmd HttpHeaders] method to stream the MIME headers out of the socket - -[enum] -Invokes the [cmd {request parse}] method to convert the stream of MIME headers into a -dict that can be read via the [cmd request] method. - -[enum] -Stores the raw stream of MIME headers in the [arg rawrequest] variable of the object. - -[enum] -Invokes the [cmd content] method for the object, generating an call to the [cmd error] -method if an exception is raised. - -[enum] -Invokes the [cmd output] method for the object -[list_end] - -[para] - -[section {Reply Method Ensembles}] - -The [cmd http::reply] class and its derivatives maintain several variables as dictionaries -internally. Access to these dictionaries is managed through a dedicated ensemble. The -ensemble implements most of the same behaviors as the [cmd dict] command. - -Each ensemble implements the following methods above, beyond, or modifying standard dicts: - -[list_begin definitions] - -[call method [cmd ENSEMBLE::add] [arg field] [arg element]] - -Add [arg element] to a list stored in [arg field], but only if it is not already present om the list. - -[call method [cmd ENSEMBLE::dump]] - -Return the current contents of the data structure as a key/value list. - -[call method [cmd ENSEMBLE::get] [arg field]] - -Return the value of the field [arg field], or an empty string if it does not exist. - -[call method [cmd ENSEMBLE::reset]] - -Return a key/value list of the default contents for this data structure. - -[call method [cmd ENSEMBLE::remove] [arg field] [arg element]] - -Remove all instances of [arg element] from the list stored in [arg field]. - -[call method [cmd ENSEMBLE::replace] [arg keyvaluelist]] - -Replace the internal dict with the contents of [arg keyvaluelist] - -[call method [cmd ENSEMBLE::reset]] - -Replace the internal dict with the default state. - -[call method [cmd ENSEMBLE::set] [arg field] [arg value]] - -Set the value of [arg field] to [arg value]. - -[list_end] - -[section {Reply Method Ensemble: http_info}] - -Manages HTTP headers passed in by the server. - -Ensemble Methods: - -[list_begin definitions] - -[call method [cmd http_info::netstring]] - -Return the contents of this data structure as a netstring encoded block. - -[list_end] - -[section {Reply Method Ensemble: request}] - -Managed data from MIME headers of the request. - -[list_begin definitions] - -[call method [cmd request::parse] [arg string]] - -Replace the contents of the data structure with information encoded in a MIME -formatted block of text ([arg string]). - -[list_end] - -[section {Reply Method Ensemble: reply}] - -Manage the headers sent in the reply. - - -[list_begin definitions] - -[call method [cmd reply::output]] - -Return the contents of this data structure as a MIME encoded block appropriate -for an HTTP response. - -[list_end] - -[section {Reply Methods}] - -[list_begin definitions] -[call method [cmd close]] - -Terminate the transaction, and close the socket. - -[call method [cmd HttpHeaders] [arg sock] [arg ?debug?]] - -Stream MIME headers from the socket [arg sock], stopping at an empty line. Returns -the stream as a block of text. - -[call method [cmd dispatch] [arg newsock] [arg datastate]] - -Take over control of the socket [arg newsock], and store that as the [arg chan] variable -for the object. This method runs through all of the steps of reading HTTP headers, generating -content, and closing the connection. (See class writetup). - -[call method [cmd error] [arg code] [arg ?message?] [arg ?errorInfo?]] - -Generate an error message of the specified [arg code], and display the [arg message] as the -reason for the exception. [arg errorInfo] is passed in from calls, but how or if it should be -displayed is a prerogative of the developer. - -[call method [cmd content]] - -Generate the content for the reply. This method is intended to be replaced by the mixin. - -Developers have the option of streaming output to a buffer via the [cmd puts] method of the -reply, or simply populating the [arg reply_body] variable of the object. -The information returned by the [cmd content] method is not interpreted in any way. - -If an exception is thrown (via the [cmd error] command in Tcl, for example) the caller will -auto-generate a 500 {Internal Error} message. - -A typical implementation of [cmd content] look like: - -[example { - -tool::define ::test::content.file { - superclass ::httpd::content.file - # Return a file - # Note: this is using the content.file mixin which looks for the reply_file variable - # and will auto-compute the Content-Type - method content {} { - my reset - set doc_root [my http_info get doc_root] - my variable reply_file - set reply_file [file join $doc_root index.html] - } -} -tool::define ::test::content.time { - # return the current system time - method content {} { - my variable reply_body - my reply set Content-Type text/plain - set reply_body [clock seconds] - } -} -tool::define ::test::content.echo { - method content {} { - my variable reply_body - my reply set Content-Type [my request get CONTENT_TYPE] - set reply_body [my PostData [my request get CONTENT_LENGTH]] - } -} -tool::define ::test::content.form_handler { - method content {} { - set form [my FormData] - my reply set Content-Type {text/html; charset=UTF-8} - my puts [my html header {My Dynamic Page}] - my puts "" - my puts "You Sent

" - my puts "" - foreach {f v} $form { - my puts "" - } - my puts "
$f$v

" - my puts "Send some info:

" - my puts "" - my puts "" - foreach field {name rank serial_number} { - set line "" - my puts $line - } - my puts "
$field
" - my puts [my html footer] - } -} - -}] - -[call method [cmd EncodeStatus] [arg status]] - -Formulate a standard HTTP status header from he string provided. - -[call method FormData] - -For GET requests, converts the QUERY_DATA header into a key/value list. - -For POST requests, reads the Post data and converts that information to -a key/value list for application/x-www-form-urlencoded posts. For multipart -posts, it composites all of the MIME headers of the post to a singular key/value -list, and provides MIME_* information as computed by the [cmd mime] package, including -the MIME_TOKEN, which can be fed back into the mime package to read out the contents. - -[call method MimeParse [arg mimetext]] - -Converts a block of mime encoded text to a key/value list. If an exception is encountered, -the method will generate its own call to the [cmd error] method, and immediately invoke -the [cmd output] method to produce an error code and close the connection. - -[call method [cmd DoOutput]] - -Generates the the HTTP reply, and streams that reply back across [arg chan]. - -[call method PostData [arg length]] - -Stream [arg length] bytes from the [arg chan] socket, but only of the request is a -POST or PUSH. Returns an empty string otherwise. - -[call method [cmd puts] [arg string]] - -Appends the value of [arg string] to the end of [arg reply_body], as well as a trailing newline -character. - -[call method [cmd reset]] - -Clear the contents of the [arg reply_body] variable, and reset all headers in the [cmd reply] -structure back to the defaults for this object. - -[call method [cmd timeOutCheck]] - -Called from the [cmd http::server] object which spawned this reply. Checks to see -if too much time has elapsed while waiting for data or generating a reply, and issues -a timeout error to the request if it has, as well as destroy the object and close the -[arg chan] socket. - -[call method [cmd timestamp]] - -Return the current system time in the format: [example {%a, %d %b %Y %T %Z}] - -[call method [cmd TransferComplete] [arg args]] - -Intended to be invoked from [cmd {chan copy}] as a callback. This closes every channel -fed to it on the command line, and then destroys the object. - -[example { - ### - # Output the body - ### - chan configure $sock -translation binary -blocking 0 -buffering full -buffersize 4096 - chan configure $chan -translation binary -blocking 0 -buffering full -buffersize 4096 - if {$length} { - ### - # Send any POST/PUT/etc content - ### - chan copy $sock $chan -size $SIZE -command [info coroutine] - yield - } - catch {close $sock} - chan flush $chan -}] - -[call method [cmd Url_Decode] [arg string]] - -De-httpizes a string. - -[list_end] ADDED modules/httpd/build/server.inc Index: modules/httpd/build/server.inc ================================================================== --- /dev/null +++ modules/httpd/build/server.inc @@ -0,0 +1,97 @@ +[section {Class ::httpd::server}] + +This class is the root object of the webserver. It is responsible +for opening the socket and providing the initial connection negotiation. + +[list_begin definitions] +[call constructor ?port [opt port]? ?myaddr [opt ipaddr]|all? ?server_string [opt string]? ?server_name [opt string]?] +Build a new server object. [opt port] is the port to listen on + +[call method [cmd add_uri] [arg pattern] [arg dict]] +Set the hander for a URI pattern. Information given in the [arg dict] is stored +in the data structure the [cmd dispatch] method uses. If a field called +[arg mixin] is given, that class will be mixed into the reply object immediately +after construction. + +[call method [cmd connect] [arg sock] [arg ip] [arg port]] + +Reply to an open socket. This method builds a coroutine to manage the remainder +of the connection. The coroutine's operations are driven by the [cmd Connect] method. + +[call method [cmd Connect] [arg uuid] [arg sock] [arg ip]] + +This method reads HTTP headers, and then consults the [cmd dispatch] method to +determine if the request is valid, and/or what kind of reply to generate. Under +normal cases, an object of class [cmd ::http::reply] is created. + +Fields the server are looking for in particular are: + +class: A class to use instead of the server's own [arg reply_class] + +mixin: A class to be mixed into the new object after construction. + +All other fields are passed along to the [cmd http_info] structure of the +reply object. + +After the class is created and the mixin is mixed in, the server invokes the +reply objects [cmd dispatch] method. This action passes control of the socket to +the reply object. The reply object manages the rest of the transaction, including +closing the socket. + +[call method [cmd counter] [arg which]] + +Increment an internal counter. + +[call method [cmd CheckTimeout]] + +Check open connections for a time out event. + +[call method [cmd dispatch] [arg header_dict]] + +Given a key/value list of information, return a data structure describing how +the server should reply. + +[call method [cmd log] [arg args]] + +Log an event. The input for args is free form. This method is intended +to be replaced by the user, and is a noop for a stock http::server object. + +[call method [cmd port_listening]] + +Return the actual port that httpd is listening on. + +[call method [cmd PrefixNormalize] [arg prefix]] + +For the stock version, trim trailing /'s and *'s from a prefix. This +method can be replaced by the end user to perform any other transformations +needed for the application. + +[call method [cmd start]] + +Open the socket listener. + +[call method [cmd stop]] + +Shut off the socket listener, and destroy any pending replies. + +[call method [cmd template] [arg page]] + +Return a template for the string [arg page] + +[call method [cmd TemplateSearch] [arg page]] + +Perform a search for the template that best matches [arg page]. This +can include local file searches, in-memory structures, or even +database lookups. The stock implementation simply looks for files +with a .tml or .html extension in the [opt doc_root] directory. + +[call method [cmd Validate_Connection] [arg sock] [arg ip]] + + +Given a socket and an ip address, return true if this connection should +be terminated, or false if it should be allowed to continue. The stock +implementation always returns 0. This is intended for applications to +be able to implement black lists and/or provide security based on IP +address. + +[list_end] DELETED modules/httpd/build/server.man Index: modules/httpd/build/server.man ================================================================== --- modules/httpd/build/server.man +++ /dev/null @@ -1,97 +0,0 @@ -[section {Class ::httpd::server}] - -This class is the root object of the webserver. It is responsible -for opening the socket and providing the initial connection negotiation. - -[list_begin definitions] -[call constructor ?port [opt port]? ?myaddr [opt ipaddr]|all? ?server_string [opt string]? ?server_name [opt string]?] -Build a new server object. [opt port] is the port to listen on - -[call method [cmd add_uri] [arg pattern] [arg dict]] -Set the hander for a URI pattern. Information given in the [arg dict] is stored -in the data structure the [cmd dispatch] method uses. If a field called -[arg mixin] is given, that class will be mixed into the reply object immediately -after construction. - -[call method [cmd connect] [arg sock] [arg ip] [arg port]] - -Reply to an open socket. This method builds a coroutine to manage the remainder -of the connection. The coroutine's operations are driven by the [cmd Connect] method. - -[call method [cmd Connect] [arg uuid] [arg sock] [arg ip]] - -This method reads HTTP headers, and then consults the [cmd dispatch] method to -determine if the request is valid, and/or what kind of reply to generate. Under -normal cases, an object of class [cmd ::http::reply] is created. - -Fields the server are looking for in particular are: - -class: A class to use instead of the server's own [arg reply_class] - -mixin: A class to be mixed into the new object after construction. - -All other fields are passed along to the [cmd http_info] structure of the -reply object. - -After the class is created and the mixin is mixed in, the server invokes the -reply objects [cmd dispatch] method. This action passes control of the socket to -the reply object. The reply object manages the rest of the transaction, including -closing the socket. - -[call method [cmd counter] [arg which]] - -Increment an internal counter. - -[call method [cmd CheckTimeout]] - -Check open connections for a time out event. - -[call method [cmd dispatch] [arg header_dict]] - -Given a key/value list of information, return a data structure describing how -the server should reply. - -[call method [cmd log] [arg args]] - -Log an event. The input for args is free form. This method is intended -to be replaced by the user, and is a noop for a stock http::server object. - -[call method [cmd port_listening]] - -Return the actual port that httpd is listening on. - -[call method [cmd PrefixNormalize] [arg prefix]] - -For the stock version, trim trailing /'s and *'s from a prefix. This -method can be replaced by the end user to perform any other transformations -needed for the application. - -[call method [cmd start]] - -Open the socket listener. - -[call method [cmd stop]] - -Shut off the socket listener, and destroy any pending replies. - -[call method [cmd template] [arg page]] - -Return a template for the string [arg page] - -[call method [cmd TemplateSearch] [arg page]] - -Perform a search for the template that best matches [arg page]. This -can include local file searches, in-memory structures, or even -database lookups. The stock implementation simply looks for files -with a .tml or .html extension in the [opt doc_root] directory. - -[call method [cmd Validate_Connection] [arg sock] [arg ip]] - - -Given a socket and an ip address, return true if this connection should -be terminated, or false if it should be allowed to continue. The stock -implementation always returns 0. This is intended for applications to -be able to implement black lists and/or provide security based on IP -address. - -[list_end] Index: modules/httpd/httpd.man ================================================================== --- modules/httpd/httpd.man +++ modules/httpd/httpd.man @@ -51,13 +51,13 @@ } ::docserver::server create HTTPD port 8015 myaddr 127.0.0.1 HTTPD add_uri /* [list mixin reply.hello] }] -[include build/server.man] -[include build/reply.man] -[include build/content.man] +[include build/server.inc] +[include build/reply.inc] +[include build/content.inc] [section AUTHORS] Sean Woods [vset CATEGORY network]