ksgi

Форк
0
/
test-returncode.c 
67 строк · 1.7 Кб
1
/*	$Id$ */
2
/*
3
 * Copyright (c) 2016 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
	long	 http;
33

34
	curl_easy_setopt(curl, CURLOPT_URL, 
35
		"http://localhost:17123/");
36
	if (CURLE_OK != curl_easy_perform(curl))
37
		return(0);
38
	curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http);
39
	return(415 == http);
40
}
41

42
static int
43
child(void)
44
{
45
	struct kreq	 r;
46
	const char 	*page = "index";
47

48
	if (khttp_fcgi_test())
49
		return(0);
50

51
	if (KCGI_OK != khttp_parse(&r, NULL, 0, &page, 1, 0))
52
		return(0);
53
	khttp_head(&r, kresps[KRESP_STATUS], 
54
		"%s", khttps[KHTTP_415]);
55
	khttp_head(&r, kresps[KRESP_CONTENT_TYPE], 
56
		"%s", kmimetypes[KMIME_TEXT_HTML]);
57
	khttp_body(&r);
58
	khttp_free(&r);
59
	return(1);
60
}
61

62
int
63
main(int argc, char *argv[])
64
{
65

66
	return(regress_cgi(parent, child) ? EXIT_SUCCESS : EXIT_FAILURE);
67
}
68

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

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

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

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