3
* Copyright (c) 2015 Kristaps Dzonsons <kristaps@bsd.lv>
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.
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.
31
doign(void *ptr, size_t sz, size_t nm, void *arg)
34
*(size_t *)arg += sz * nm;
44
p = malloc(1024 * 1024 + 5);
45
strncpy(p, "tag=", 5);
46
for (i = 0; i < 1024 * 1024; i++)
47
p[i + 4] = (i % 10) + 65;
48
p[1024 * 1024 + 4] = '\0';
51
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, doign);
52
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &i);
53
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, p);
54
curl_easy_setopt(curl, CURLOPT_URL,
55
"http://localhost:17123/");
56
if (CURLE_OK != curl_easy_perform(curl)) {
61
return(i >= 1024 * 1024);
68
const char *page = "index";
69
struct kvalid valid = { NULL, "tag" };
74
if (KCGI_OK != khttp_fcgi_init(&fcgi, &valid, 1, &page, 1, 0))
77
while (KCGI_OK == (er = khttp_fcgi_parse(fcgi, &r))) {
78
if (NULL == r.fieldmap[0]) {
80
khttp_fcgi_free(fcgi);
82
} else if (1024 * 1024 != r.fieldmap[0]->valsz) {
84
khttp_fcgi_free(fcgi);
88
for (i = 0; i < 1024 * 1024; i++)
89
if ((unsigned char)r.fieldmap[0]->val[i] !=
92
khttp_fcgi_free(fcgi);
96
khttp_head(&r, kresps[KRESP_STATUS],
97
"%s", khttps[KHTTP_200]);
98
khttp_head(&r, kresps[KRESP_CONTENT_TYPE],
99
"%s", kmimetypes[KMIME_TEXT_HTML]);
101
khttp_write(&r, r.fieldmap[0]->val, r.fieldmap[0]->valsz);
106
khttp_fcgi_free(fcgi);
107
return(KCGI_HUP == er ? 1 : 0);
111
main(int argc, char *argv[])
114
return(regress_fcgi(parent, child) ? EXIT_SUCCESS : EXIT_FAILURE);