@Test
void form() {

    var request = new HTTPRequest(HTTPMethod.POST, "http://localhost/uri");
    Map<String, String> form = new LinkedHashMap<>();   // make order deterministic
    form.put("key1", "v1 v2");
    form.put("key2", "v1+v2");
    request.form(form);
    assertThat(request.contentType).isEqualTo(ContentType.APPLICATION_FORM_URLENCODED);
    assertThat(request.headers).containsEntry(HTTPHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
    assertThat(new String(request.body, UTF_8)).isEqualTo("key1=v1+v2&key2=v1%2Bv2");
    assertThatThrownBy(() -> new HTTPRequest(HTTPMethod.PUT, "http://localhost/uri").form(Map.of()))
            .isInstanceOf(Error.class)
            .hasMessageContaining("form must be used with POST");
}