3
.\" Copyright (c) 2020 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.
22
.Nd open kcgijson context
33
.Fa "struct kjsonreq *req"
37
Zeroes and initialises a new context
46
.Xr khttp_fcgi_parse 3 .
47
It should only be called after
50
The scope open after initialisation is the
52
scope, which accepts similar content as arrays such as
55
.Xr kjson_putstringp 3 .
58
.Xr kcgi_writer_disable 3
59
has been called, the process will be killed with an uncatchable signal.
63
indicating the error state.
66
Success (not an error).
68
Internal memory allocation failure.
70
The output connection has been terminated.
71
For FastCGI connections, the current connection should be released with
73
and parse loop reentered.
75
The connection is still expecting headers with
79
did not return with success or was not invoked.
80
For FastCGI connections, the current connection should be released with
82
and parse loop reentered.
84
Internal system error writing to the output stream.
87
The following outputs a simple JSON page.
93
For brevity, it does not do any error checking.
94
.Bd -literal -offset indent
95
khttp_head(r, kresps[KRESP_STATUS],
96
"%s", khttps[KHTTP_200]);
97
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
98
"%s", kmimetypes[KMIME_APP_JSON]);
102
kjson_putstringp(&req, "foo", "bar");
109
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .