An HTTP client.
// Create a new HTTP client auto http = new Http(); // We'll work on http://www.sfml-dev.org http.setHost("http://www.sfml-dev.org"); // Prepare a request to get the 'features.php' page auto request = new Http.Request("features.php"); // Send the request auto response = http.sendRequest(request); // Check the status code and display the result auto status = response.getStatus(); if (status == Http.Response.Status.Ok) { writeln(response.getBody()); } else { writeln("Error ", status); }
The Http class is a very simple HTTP client that allows you to communicate with a web server. You can retrieve web pages, send data to an interactive resource, download a remote file, etc. The HTTPS protocol is not supported.
The HTTP client is split into 3 classes:
$(PARA Http.Request builds the request that will be sent to the server. A request is made of:)
$(PARA Http.Response parses the response from the web server and provides getters to read them. The response contains:)
$(PARA $(U Http) provides a simple function, `sendRequest`, to send a Http.Request and return the corresponding Http.Response from the server.)