Scol standard library package
0.3.1
Common and usefull functions for all Scol applications
|
Functions | |
std_netBuildListFromParams (szParams) | |
Function to convert a string parameters like a=b&c=d ... to a list key,value. The given string should be already parsed (the params only). | |
std_netCheckConnection (szUrl, cbfun) | |
Check if a server can be joined. | |
std_netGetBody (szReq) | |
Return the body of a received request object. | |
std_netGetDomain (url) | |
Return the domain (or the IP address if any) in an url. | |
std_netGetHeader (szReq) | |
Return the header of a received request object. | |
std_netGetParamsInUrl (szUrl) | |
Return the params of a received GET request string. | |
std_netParseRequest (szReq) | |
Parse a received request. |
Detailed Description
Package to load : lib/std/net.pkg
Dependancies :
Function Documentation
std_netGetDomain | ( | url | ) |
Return the domain (or the IP address if any) in an url.
"http://www.example.com:1234/dir/file.html" -> "www.example.com"
"http://www.example.com/dir/file.html" -> "www.example.com"
"http://1.2.3.4:1234/dir/file.html" -> "1.2.3.4"
Prototype : fun [S] S
- Parameters
-
S : an url
- Returns
- S : the domain or nil if undefined
- Remarks
- Known protocols : http, https, file, ftp, ftps, sftp, scol.
std_netParseRequest | ( | szReq | ) |
Parse a received request.
Prototype :fun [S] [S S S S S S S S S S [[S S] r1]]
- Parameters
-
S : a string received request
- Returns
- [S S S S S S S S S S [[S S] r1]] : a tuple :
- S : the "host",
- S : the "port" (80 by default),
- S : the "user agent",
- S : the used HTTP "protocol" (generally 1.0 or 1.1),
- S : the "verb" (GET, POST, ...),
- S : the data type (= the value of "Content-Type" header),
- S : the language (= the value of "Content-Language" or "Accept-Language" header),
- S : the size(lenght) of :
- the "url", if the "verb" is "GET",
- the "body" (exactly the value of the "Content-Lenght" header), if the "verb" is "POST",
- S : the asked "url" (without the host),
- S : the "body", the body content, if the "verb" is "POST" (should be nil with "GET"),
- [[S S] r1] : a list with key, value which have been received in the request. If unable to find keys,values but the string is not empty, the string is returned in the first item of the tuple (in this case, the list has one element (tuple) only).
- Remarks
- If a value is not found, it will be nil, except for the port.
std_netGetHeader | ( | szReq | ) |
Return the header of a received request object.
Prototype :fun [S] S
- Parameters
-
S : a valid request string
- Returns
- S : the header or nil if the request is invalid
std_netGetBody | ( | szReq | ) |
Return the body of a received request object.
Prototype :fun [S] S
- Parameters
-
S : a valid request string
- Returns
- S : the body or nil if no body found (with "GET" by example)
std_netBuildListFromParams | ( | szParams | ) |
Function to convert a string parameters like a=b&c=d ... to a list key,value. The given string should be already parsed (the params only).
Prototype :fun [S] [[S S] r1]
- Parameters
-
S : an already parsed string, typically from an url (GET) or a body (POST)
"param1=a¶m2=b" -> [["param1" "a"] :: ["param2" "b"] :: nil
- Returns
- [[S S] r1] : this list or nil if the request is invalid
- Remarks
- If this function is unable to find keys,values, it returns a list with one tuple only, the full string is in the first item of the tuple.
- See Also
- std_netGetParamsInUrl
std_netGetParamsInUrl | ( | szUrl | ) |
Return the params of a received GET request string.
"http://domain.tld/dir/file.ext?param1=a¶m2=b" -> "param1=a¶m2=b"
Prototype :fun [S] S
- Parameters
-
S : a valid request string
- Returns
- S : the params or nil if not found
- See Also
- std_netBuildListFromParams
std_netCheckConnection | ( | szUrl | , |
cbfun | |||
) |
Check if a server can be joined.
Prototype :fun [S fun [I] I] I
- Parameters
-
S : an url to check fun [I] I : a function to call when the connection is checked. Its argument will be 1 if success.
- Returns
- I : always 0
Generated on Sat Jan 31 2015 19:15:44 for Scol standard library package by 1.8.1.2