Пример #1
0
void
test_parse_authorization(void)
{
    g_assert(balde_parse_authorization(NULL) == NULL);
    g_assert(balde_parse_authorization("") == NULL);
    g_assert(balde_parse_authorization("Bola afddsfsdfdsgfdg") == NULL);
    g_assert(balde_parse_authorization("Basic Ym9sYQ==") == NULL);  // bola
    balde_authorization_t *a = balde_parse_authorization("Basic Ym9sYTpndWRh");  // bola:guda
    g_assert(a != NULL);
    g_assert_cmpstr(a->username, ==, "bola");
    g_assert_cmpstr(a->password, ==, "guda");
    balde_authorization_free(a);
    a = balde_parse_authorization("Basic Ym9sYTo=");  // bola:
    g_assert(a != NULL);
    g_assert_cmpstr(a->username, ==, "bola");
    g_assert_cmpstr(a->password, ==, "");
    balde_authorization_free(a);
    a = balde_parse_authorization("Basic Ym9sYTpndWRhOmxvbA==");  // bola:guda:lol
    g_assert(a != NULL);
    g_assert_cmpstr(a->username, ==, "bola");
    g_assert_cmpstr(a->password, ==, "guda:lol");
    balde_authorization_free(a);
}
Пример #2
0
void
balde_request_free(balde_request_t *request)
{
    if (request == NULL)
        return;
    g_free((gchar*) request->path);
    g_free((gchar*) request->server_name);
    g_free((gchar*) request->script_name);
    g_hash_table_destroy(request->priv->headers);
    g_hash_table_destroy(request->priv->args);
    if (request->priv->view_args != NULL)
        g_hash_table_destroy(request->priv->view_args);
    if (request->priv->body != NULL)
        g_string_free(request->priv->body, TRUE);
    if (request->priv->form != NULL)
        g_hash_table_destroy(request->priv->form);
    if (request->priv->files != NULL)
        g_hash_table_destroy(request->priv->files);
    if (request->priv->cookies != NULL)
        g_hash_table_destroy(request->priv->cookies);
    balde_authorization_free(request->authorization);
    g_free(request->priv);
    g_free(request);
}