Revision [1457]

This is an old revision of CommandHttpserver made by DavidLee on 2010-06-10 07:02:36.

 

Command httpserver


Name

httpserver http server

Synopsis

httpserver [options] [start|stop]

Note: This command is part of the Experimental Commands set and needs to be imported in order to be used.

This command is still under development and is expected to change substantially.

Httpserver starts or stops a single thread which runs an HTTP server within the current shell.
The server is run as a background thread so the command returns immedeately.
Processing of requests is entirely scripted.


Options


-port portListen on the specified port (default 80)
-context pathResponds to requests on the given context (default "/")
-get cmdExecutes cmd when handling a GET request
-put cmdExecutes cmd when handling a PUT request
-post cmd Executes cmd when handling a POST request
-chunkOperates in HTTP Chunked mode (default is off)

startStarts the HTTP server
stopStops the HTTP server


Usage


On invocation of a method, $1 is set to the file part of the URI, $2 is set to the query portion of the URI.
The HTTP Request body is made available as stdin to the command, and the output of the command becomes the Response portion.

Like xmlsh servlet the global variable _HEADERS is set as with all HTTP headers.



Examples


Start a server that serves the file specified by the URL given.
import commands posix
httpserver -port 80 -get 'cat $(xfile . $1)' start





Return Value





Commands
CategoryCommands
CommandsExperimental

There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki