ksgi
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
29static int30parent(CURL *curl)31{
32long http;33
34curl_easy_setopt(curl, CURLOPT_URL,35"http://localhost:17123/");36if (CURLE_OK != curl_easy_perform(curl))37return(0);38curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http);39return(415 == http);40}
41
42static int43child(void)44{
45struct kreq r;46const char *page = "index";47
48if (khttp_fcgi_test())49return(0);50
51if (KCGI_OK != khttp_parse(&r, NULL, 0, &page, 1, 0))52return(0);53khttp_head(&r, kresps[KRESP_STATUS],54"%s", khttps[KHTTP_415]);55khttp_head(&r, kresps[KRESP_CONTENT_TYPE],56"%s", kmimetypes[KMIME_TEXT_HTML]);57khttp_body(&r);58khttp_free(&r);59return(1);60}
61
62int
63main(int argc, char *argv[])64{
65
66return(regress_cgi(parent, child) ? EXIT_SUCCESS : EXIT_FAILURE);67}
68