Urdl C++ Library

PrevUpHomeNext

Setting options to perform an HTTP POST

To upload over HTTP, we set the http::request_method, http::request_content and http::request_content_type options on the stream prior to opening the URL:

// For the HTTP options.
#include <urdl/http.hpp>

...

urdl::istream is;

// We're doing an HTTP POST ...
is.set_option(urdl::http::request_method("POST"));

// ... where the MIME type indicates plain text ...
is.set_option(urdl::http::request_content_type("text/plain"));

// ... and here's the content.
is.set_option(urdl::http::request_content("Hello, world!"));

// All options set, so now we can open the URL.
is.open("http://somehost/path");

PrevUpHomeNext