writeFormBody

Writes a vibe.http.client.HTTPClientRequest body as URL encoded form data.

  1. void writeFormBody(HTTPClientRequest req, string[string] form)
    void
    writeFormBody
    (,
    in string[string] form
    )
  2. void writeFormBody(HTTPClientRequest req, PairRange form)

Examples

import vibe.core.log;
import vibe.http.client;
import vibe.http.form;
import vibe.stream.operations;

void sendForm()
{
	requestHTTP("http://example.com/form",
		(scope req) {
			req.method = HTTPMethod.POST;
			req.writeFormBody(["field1": "value1", "field2": "value2"]);
		},
		(scope res) {
			logInfo("Response: %s", res.bodyReader.readAllUTF8());
		});
}

Meta