Http$
Takes 9 parameters, ServerName, Port, bSecure, Mode, Path, [ContentType], [extraHeader], [body], [rtnHeaders]
Description:
Perform an HTTP or HTTPS request to a designated server and port.
- ServerName - The IPv4 Address or Domain Name of the destination server.
- Port - If blank, this will default to 80 or 443 depending on bSecure.
- bSecure - Boolean value which determines if the request will be HTTP or HTTPS.
- Mode - If blank, this will default to POST, otherwise configure this to GET, DELETE, PUT, PATCH, etc.
- Path - The rest of the path which will concatenated to the end of the ServerName.
- ContentType - If blank, this will default application/lx-www-form-urlencoded.
- ExtraHeader - Allows the use of any additional Headers.
- Body - The body of a POST, if using application/lx-www-form-urlencoded, be sure to use UrlEncode$ on each value included
- RtnHeader - A boolean value which determines if this function will return the Response Headers from the request.
- When using this option, non-200 OK response values will not generate a runtime error; the developer can then parse the headers from the body and handle various response types. This can be done as follows:
[New] Head, Body
Head = Extract$ Recv, ($CrLf & $CrLF)
Body = Remain$ Recv, ($CrLf & $CrLF)
Example:
[New] HttpBody HttpPath HttpParams HttpContentType HttpXHeader
HttpBody = ""
HttpPath = "/comments"
HttpParams = "userid=1"
HttpContentType = "application/json"
HttpXHeader = ""
[New] HttpResponse = Http$ "jsonplaceholder.typicode.com", "", "", "GET", (HttpPath & HttpParams), HttpContentType, HttpXHeader, HttpBody, ""