haXe API Documentation
Back | Index
class neko.Web
Available in neko
This class is used for accessing the local Web server and the current client request and informations.
static var isModNeko(default,null) : Bool
static var isTora(default,null) : Bool
static function cacheModule(f : Void -> Void) : Void
Set the main entry point function used to handle requests. Setting it back to null will disable code caching.
static function flush() : Void
Flush the data sent to the client. By default on Apache, outgoing data is buffered so this can be useful for displaying some long operation progress.
static function getAuthorization() : { user : String, pass : String}
Returns an object with the authorization sent by the client (Basic scheme only).
static function getClientHeader(k : String) : String
Retrieve a client header value sent with the request.
static function getClientHeaders() : List<{ value : String, header : String}>
Retrieve all the client headers.
static function getClientIP() : String
Surprisingly returns the client IP address.
static function getCookies() : Hash<String>
Returns an hashtable of all Cookies sent by the client. Modifying the hashtable will not modify the cookie, use setCookie instead.
static function getCwd() : String
Get the current script directory in the local filesystem.
static function getHostName() : String
Returns the local server host name
static function getMethod() : String
Get the HTTP method used by the client. This api requires Neko 1.7.1+
static function getMultipart(maxSize : Int) : Hash<String>
Get the multipart parameters as an hashtable. The data cannot exceed the maximum size specified.
static function getParamValues(param : String) : Array<String>
Returns an Array of Strings built using GET / POST values. If you have in your URL the parameters a[]=foo;a[]=hello;a[5]=bar;a[3]=baz then neko.Web.getParamValues("a") will return ["foo","hello",null,"baz",null,"bar"]
static function getParams() : Hash<String>
Returns the GET and POST parameters.
static function getParamsString() : String
Returns all the GET parameters String
static function getPostData() : String
Returns all the POST data. POST Data is always parsed as being application/x-www-form-urlencoded and is stored into the getParams hashtable. POST Data is maximimized to 256K unless the content type is multipart/form-data. In that case, you will have to use getMultipart or parseMultipart methods.
static function getURI() : String
Returns the original request URL (before any server internal redirections)
static function logMessage(msg : String) : Void
Write a message into the web server log file. This api requires Neko 1.7.1+
static function parseMultipart(onPart : String -> String -> Void, onData : haxe.io.Bytes -> Int -> Int -> Void) : Void
Parse the multipart data. Call onPart when a new part is found with the part name and the filename if present and onData when some part data is readed. You can this way directly save the data on hard drive in the case of a file upload.
static function redirect(url : String) : Void
Tell the client to redirect to the given url ("Location" header)
static function setCookie(key : String, value : String, ?expire : Date, ?domain : String, ?path : String, ?secure : Bool) : Void
Set a Cookie value in the HTTP headers. Same remark as setHeader.
static function setHeader(h : String, v : String) : Void
Set an output header value. If some data have been printed, the headers have already been sent so this will raise an exception.
static function setReturnCode(r : Int) : Void
Set the HTTP return code. Same remark as setHeader.
Back | Index