Exemplo n.º 1
0
void
test_request_get_form(void)
{
    g_setenv("REQUEST_METHOD", "GET", TRUE);
    // FIXME: this thing is too weak :(
    balde_app_t *app = balde_app_init();
    balde_request_t *request = balde_make_request(app);
    g_assert(request->stream == NULL);
    g_assert(request->form == NULL);
    g_assert(balde_request_get_form(request, "lol") == NULL);
    balde_request_free(request);
    balde_app_free(app);
}
Exemplo n.º 2
0
void
test_request_get_form_with_empty_body(void)
{
    g_setenv("REQUEST_METHOD", "POST", TRUE);
    // FIXME: this thing is too weak :(
    balde_app_t *app = balde_app_init();
    // ommited CONTENT_LENGTH
    balde_request_t *request = balde_make_request(app);
    g_assert(request->stream == NULL);
    g_assert(g_hash_table_size(request->form) == 0);
    g_assert(balde_request_get_form(request, "lol") == NULL);
    balde_request_free(request);
    balde_app_free(app);
}
Exemplo n.º 3
0
balde_response_t*
hello(balde_app_t *app, balde_request_t *request)
{
    balde_response_t *response = balde_make_response("");
    if (request->method == BALDE_HTTP_POST) {
        const gchar *name = balde_request_get_form(request, "name");
        balde_response_set_tmpl_var(response, "name",
            name != NULL && name[0] != '\0' ? name : "World");
        balde_template_hello(app, request, response);
    }
    else
        balde_template_form(app, request, response);
    return response;
}