#include <rtnetwork.h>
Public Types | |||||
| enum | HttpMethod { GET = 0, POST = 1, HEAD = 2 } | ||||
| HTTP Request method. Currently supported: GET, POST and HEAD. | |||||
Static Public Methods | |||||
| Socket * | create (const String &server, int port) | ||||
creates a client socket
| |||||
| ServerSocket * | createServer (int port) | ||||
creates a server socket
| |||||
| const Time & | getTimeout () | ||||
| Get the maximum waiting duration before the socket read operation is stopped. | |||||
| void | setTimeout (const Time &) | ||||
| Set the maximum waiting duration before a socket read operation is cancelled Initially, this is set to 60 seconds to avoid application blocking. You can set the timeout to zero (Time()) to disable timeout entirely. | |||||
| void | splitURL (const String &url, String &proto, String &server, int &port, String &file) | ||||
| Splits an URL into protocol, server, port and file. Components that are not given in the original url are set to their default values. | |||||
| bool | httpRequest (const String &url, HttpMethod method, Page &page) | ||||
| Performs a HTTP request. More... | |||||
| bool | httpRequest (const String &server, int port, HttpMethod method, const String &file, Page &page) | ||||
| Extended form. | |||||
| String | urlEncode (const StringMap< String > &data) | ||||
| Encodes a key-value table to an URL encoded form string. Additionally, non-acceptable characters are encoded to xx hex number fomat. | |||||
| String | urlEncode (const String &str) | ||||
| Encodes all non-acceptable characters in the given string to xx hex numbers. | |||||
Has methods for creating sockets.
|
||||||||||||||||
|
Performs a HTTP request. If you are performing a POST request, the data in page.text will be transmitted to the server. You should set the page.headers[Content-Type] appropriately before performing the request. Note especially that for sending forms to PHP pages, the default encoding text/plain does not work. You have to create a query string in the same format as for GET requests (see urlEncode()) and use the Content-Type "application/x-www-form-urlencoded". |