Line 230: |
Line 230: |
| | | |
| ===== get(url) ===== | | ===== get(url) ===== |
− | : Execute HTTP get request | + | : Execute HTTP GET request |
| : '''Argument''' | | : '''Argument''' |
− | ::; url: HTTP address, starting with http or https | + | ::; url: HTTP address, starting with http:// or https:// |
| : '''Result''' | | : '''Result''' |
| ::; HttpResult: Object containing the result of the execution of the HTTP request | | ::; HttpResult: Object containing the result of the execution of the HTTP request |
| <br/> | | <br/> |
| + | |
| + | ===== post(url, body) ===== |
| + | : Execute HTTP POST request |
| + | : '''Arguments''' |
| + | ::; url: HTTP address, starting with http:// or https:// |
| + | ::; body: The text of the HTTP POST request |
| + | : '''Result''' |
| + | ::; HttpResult: Object containing the result of the execution of the HTTP request |
| + | : '''Example''' |
| + | :: <source lang="JavaScript"> |
| + | var result = http().post("http://httpbin.org/post", "the body of the request message"); |
| + | </source> |
| + | <br/> |
| + | |
| + | ===== headers(info) ===== |
| + | : Set up header |
| + | '''Argument''' |
| + | ::; info: Header text |
| + | : '''Result''' |
| + | ::; HttpResult: Object containing the result of the execution of the HTTP request |
| + | : '''Example''' |
| + | <source lang="JavaScript"> |
| + | var http = http(); |
| + | http.headers({"User-Agent": "My Super App"}); // Set up the header |
| + | var result = http.get("http://httpbin.org/get"); // Do a GET |
| + | var headerValue = result.header("etag"); // Get response header |
| + | </source> |
| | | |
| === Object ''HttpResult'' === | | === Object ''HttpResult'' === |
| Result of the execution of the HTTP request | | Result of the execution of the HTTP request |
| | | |
− | ==== ''HttpResult'' Properties ==== | + | ==== Properties ==== |
| :; body: The response in text form | | :; body: The response in text form |
| :; code: HTTP code of the response, if the request is successful (usually 200). | | :; code: HTTP code of the response, if the request is successful (usually 200). |
| <br/> | | <br/> |
| + | |
| + | ==== '' Method'' ==== |
| + | |
| + | ===== header(tag) ===== |
| + | '''Argument''' |
| + | ::; tag: ??? |
| | | |
| === Http Examples === | | === Http Examples === |