ksgi

Форк
0
/
test-fcgi-abort-validator.c 
72 строки · 1.7 Кб
1
/*	$Id$ */
2
/*
3
 * Copyright (c) 2016, 2018 Kristaps Dzonsons <kristaps@bsd.lv>
4
 *
5
 * Permission to use, copy, modify, and distribute this software for any
6
 * purpose with or without fee is hereby granted, provided that the above
7
 * copyright notice and this permission notice appear in all copies.
8
 *
9
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
 */
17
#include "../config.h"
18

19
#include <stdarg.h>
20
#include <stdint.h>
21
#include <stdlib.h>
22
#include <unistd.h>
23

24
#include <curl/curl.h>
25

26
#include "../kcgi.h"
27
#include "regress.h"
28

29
static int
30
parent(CURL *curl)
31
{
32

33
	curl_easy_setopt(curl, CURLOPT_URL, 
34
		"http://localhost:17123/index.html?foo=bar");
35
	return CURLE_GOT_NOTHING == curl_easy_perform(curl);
36
}
37

38
static int
39
kvalid_abort(struct kpair *kp)
40
{
41

42
	abort();
43
	/* NOTREACHED */
44
	return(0);
45
}
46

47
static int
48
child(void)
49
{
50
	struct kreq	 r;
51
	const char 	*page = "index";
52
	struct kfcgi	*fcgi;
53
	struct kvalid	 key = { kvalid_abort, "foo" };
54
	enum kcgi_err	 er;
55

56
	if ( ! khttp_fcgi_test())
57
		return 0;
58
	if (KCGI_OK != khttp_fcgi_init(&fcgi, &key, 1, &page, 1, 0))
59
		return 0;
60
	if (KCGI_OK == (er = khttp_fcgi_parse(fcgi, &r)))
61
		khttp_free(&r);
62
	khttp_fcgi_free(fcgi);
63
	return KCGI_FORM == er ? 1 : 0;
64
}
65

66
int
67
main(int argc, char *argv[])
68
{
69

70
	return regress_fcgi(parent, child) ? 
71
		EXIT_SUCCESS : EXIT_FAILURE;
72
}
73

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.