about summary refs log tree commit diff
path: root/man/libhttpc_response.3
blob: 8ce283bf06b83a12b9af7fa58da9764139c1b76f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
.Dd December 13, 2024
.Dt LIBHTTPC_RESPONSE 3
.Os
.
.Sh NAME
.Nm LibHTTPC_Response
.Nd way to store HTTP responses
.
.Sh SYNOPSIS
.In libhttpc/libhttpc.h
.Ft "char *"
.Fo LibHTTPC_dumpResponse
.Fa "struct LibHTTPC_Response *response"
.Fa "char *buf"
.Fa "size_t buf_len"
.Fc
.Ft int
.Fo "LibHTTPC_writeResponse"
.Fa "int sockfd"
.Fa "struct LibHTTPC_Response *response"
.Fc
.
.Sh DESCRIPTION
.Xr libhttpc 3
stores responses
as follows:
.Bd -literal -offset indent
struct LibHTTPC_Response
{
    char                   *buf;
    const char             *version;
    enum LibHTTPC_Status    status;
    const char             *phrase;
    struct LibHTTPC_Header *headers;
    const char             *body;
    size_t                  header_count;
};
.Ed
Let's see
what means
each member:
.Bl -tag
.It Vd char *buf
Pointer to
the buffer
where response
is stored.
Presented
only for consistence,
doesn't mean anything
for the library.
.It Vd const char *version
Pointer to
the HTTP version number
.It Vd enum LibHTTPC_Status status
Response code
.It Vd const char *phrase
Explanation
of response code
.It Vd struct LibHTTPC_Header *headers
Array of headers
.It Vd const char *body
Pointer to
the entity
.It Vd size_t header_count
Length of
.Ql header_count
array
.
.Pp
.Ql LibHTTPC_dumpResponse
function combines
contents of
.Ql response
in the buffer.
.
.Pp
.Ql LibHTTPC_writeResponse
function writes
.Ql response
to the
.Ql sockfd .
.
.Pp
Both functions can
autocomplete responses.
If
.Ql version
is
.Ql NULL ,
then it will
be set to
.Ql "HTTP/1.1" .
If
.Ql status
is 0,
then it will
be set to
200.
If
.Ql phrase
is
.Ql NULL ,
then it will
be set to
.Ql LibHTTPC_dumpStatus(status) .
.
.Sh ERRORS
.Ql LibHTTPC_writeResponse
will return 1
if cannot send
response.
.
.Sh SEE ALSO
.Xr libhttpc 3 ,
.Xr libhttpc_header ,
.Xr libhttpc_status
.
.Sh AUTHORS
.An Nakidai Perumenei Aq Mt nakidai@disroot.org
.
.Sh CAVEATS
.Ql LibHTTPC_dumpResponse
and
.Ql LibHTTPC_writeResponse
may edit fields of
.Ql response
that are set to
0