ksgi
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
29static int30parent(CURL *curl)31{
32
33curl_easy_setopt(curl, CURLOPT_URL,34"http://localhost:17123/index.html?foo=bar");35return CURLE_GOT_NOTHING == curl_easy_perform(curl);36}
37
38static int39kvalid_abort(struct kpair *kp)40{
41
42abort();43/* NOTREACHED */44return(0);45}
46
47static int48child(void)49{
50struct kreq r;51const char *page = "index";52struct kfcgi *fcgi;53struct kvalid key = { kvalid_abort, "foo" };54enum kcgi_err er;55
56if ( ! khttp_fcgi_test())57return 0;58if (KCGI_OK != khttp_fcgi_init(&fcgi, &key, 1, &page, 1, 0))59return 0;60if (KCGI_OK == (er = khttp_fcgi_parse(fcgi, &r)))61khttp_free(&r);62khttp_fcgi_free(fcgi);63return KCGI_FORM == er ? 1 : 0;64}
65
66int
67main(int argc, char *argv[])68{
69
70return regress_fcgi(parent, child) ?71EXIT_SUCCESS : EXIT_FAILURE;72}
73