예제 #1
0
static int
child(void)
{
	struct kreq	 r;
	const char 	*page = "index";
	struct kvalid	 valid = { NULL, "tag" };

	if (KCGI_OK != khttp_parse(&r, &valid, 1, &page, 1, 0))
		return(0);

	if (NULL == r.fieldmap[0]) {
		khttp_free(&r);
		return(0);
	} else if (BUFSZ != r.fieldmap[0]->valsz) {
		khttp_free(&r);
		return(0);
	}

	khttp_head(&r, kresps[KRESP_STATUS], 
		"%s", khttps[KHTTP_200]);
	khttp_head(&r, kresps[KRESP_CONTENT_TYPE], 
		"%s", kmimetypes[KMIME_TEXT_HTML]);
	khttp_body(&r);
	khttp_write(&r, r.fieldmap[0]->val, r.fieldmap[0]->valsz);
	khttp_free(&r);
	return(1);
}
예제 #2
0
static int
child(void)
{
    struct kreq	 r;
    const char 	*page = "index";
    int		 rc;

    rc = 0;
    if (khttp_fcgi_test())
        return(0);
    if (KCGI_OK != khttp_parse(&r, NULL, 0, &page, 1, 0))
        return(0);
    if (KAUTH_DIGEST != r.rawauth.type)
        goto out;
    else if (0 == r.rawauth.authorised)
        goto out;
    else if (strcmp(r.rawauth.d.digest.user, "Mufasa"))
        goto out;
    else if (strcmp(r.rawauth.d.digest.realm, "*****@*****.**"))
        goto out;
    else if (strcmp(r.rawauth.d.digest.uri, "/dir/index.html"))
        goto out;
    else if (khttpdigest_validate(&r, "Circle Of Life") <= 0)
        goto out;

    khttp_head(&r, kresps[KRESP_STATUS],
               "%s", khttps[KHTTP_200]);
    khttp_head(&r, kresps[KRESP_CONTENT_TYPE],
               "%s", kmimetypes[KMIME_TEXT_HTML]);
    khttp_body(&r);
    rc = 1;
out:
    khttp_free(&r);
    return(rc);
}
예제 #3
0
static int
child(void)
{
	struct kreq	 r;
	const char 	*page = "index";
	size_t		 i, found1, found2;

	if (KCGI_OK != khttp_parse(&r, NULL, 0, &page, 1, 0))
		return(0);

	found1 = found2 = 0;
	for (i = 0; i < r.reqsz; i++) {
		if (0 == strcmp(r.reqs[i].key, "Testing")) 
			found1 += 0 == strcmp(r.reqs[i].val, "123");
		else if (0 == strcmp(r.reqs[i].key, "Testing-Test")) 
			found2 += 0 == strcmp(r.reqs[i].val, "321");
	}

	if (1 != found1 || 1 != found2) 
		return(0);

	khttp_head(&r, kresps[KRESP_STATUS], 
		"%s", khttps[KHTTP_200]);
	khttp_head(&r, kresps[KRESP_CONTENT_TYPE], 
		"%s", kmimetypes[KMIME_TEXT_HTML]);
	khttp_body(&r);
	khttp_free(&r);
	return(1);
}
예제 #4
0
static int
child(void)
{
	struct kreq	 r;
	struct kvalid	 key = { kvalid_abort, "foo" };
	const char 	*page[] = { "index" };

	if (KCGI_OK != khttp_parse(&r, &key, 1, page, 1, 0))
		return(1);
	khttp_free(&r);
	return(0);
}
예제 #5
0
파일: test-gzip.c 프로젝트: kristapsdz/kcgi
static int
child(void)
{
	struct kreq	 r;
	const char 	*page = "index";

	if (KCGI_OK != khttp_parse(&r, NULL, 0, &page, 1, 0))
		return(0);

	khttp_head(&r, kresps[KRESP_STATUS], 
		"%s", khttps[KHTTP_200]);
	khttp_head(&r, kresps[KRESP_CONTENT_TYPE], 
		"%s", kmimetypes[KMIME_TEXT_HTML]);
	if ( ! khttp_body(&r))
		return(0);
	khttp_puts(&r, "1234567890");
	khttp_free(&r);
	return(1);
}