summary refs log tree commit diff
path: root/man/libhttpc_request.3
blob: 2fb4a7490c5a9d45cfc37f3beffebcf0d012ce94 (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
.Dd December 13, 2024
.Dt LIBHTTPC_REQUEST 3
.Os
.
.Sh NAME
.Nm LibHTTPC_Request
.Nd way to store HTTP requests
.
.Sh SYNOPSIS
.In libhttpc/libhttpc.h
.Ft "struct LibHTTPC_Request *"
.Fo LibHTTPC_loadRequest
.Fa "struct LibHTTPC_Request *request_buf"
.Fa "char *buf"
.Fc
.Ft int
.Fo LibHTTPC_Request_
.Fa "struct LibHTTPC_Request *request"
.Fc
.
.Sh DESCRIPTION
.Xr libhttpc 3
stores requests
as follows:
.Bd -literal -offset indent
struct LibHTTPC_Request
{
    char                   *buf;
    char                   *method;
    char                   *uri;
    char                   *version;
    struct LibHTTPC_Header *headers;
    char                   *body;
    size_t                  header_count;
    int                     selfalloc;
    int                     header_selfalloc;
};
.Ed
Let's see
what means
each member:
.Bl -tag
.It Vd char *buf
Pointer to
the buffer
where request
is stored
.It Vd char *method
Pointer to
the method.
It should be equal to
.Ql buf
.It Vd char *uri
Pointer to
the
.Xr uri 7
.It Vd char *version
Pointer to
the HTTP version number
.It struct LibHTTPC_Header *headers
Array of headers
.It char *body
Pointer to
the entity
.It size_t header_count
Length of
.Ql headers
array
.It int header_selfalloc
Set by the
.Ql LibHTTPC_loadRequest
function if
.Ql NULL
was passed to
request_buf argument.
Used by
.Ql LibHTTPC_Request_ .
.It int selfalloc
Set by the
.Ql LibHTTPC_loadRequest
function if
.Ql headers
array was
allocated
by the function
itself.
Used by
.Ql LibHTTPC_Request_ .
.El
.
.Pp
.Ql LibHTTPC_loadRequest
function parses
.Ql buf
and fills a
.Ql struct LibHTTPC_Request .
If
.Ql request_buf
argument
is
.Ql NULL ,
then functon will
allocate buffer
itself.
.
.Pp
.Ql LibHTTPC_Request_
function
is a destructor.
It frees array
if header_selfalloc is set,
and then frees structure
if selfalloc is set.
.
.Sh ERRORS
If
.Ql LibHTTPC_loadRequest
returned
.Ql NULL ,
you should check
.Ql errno .
If
.Ql errno
is 0,
then most likely
you forgot to call
.Ql LibHTTPC
function.
.
.Pp
If
.Ql LibHTTPC_Request_
returned -1,
you should check
.Ql errno .
.
.Sh SEE ALSO
.Xr libhttpc 3 ,
.Xr libhttpc-alloc 3 ,
.Xr libhttpc_header 3
.
.Sh AUTHORS
.An Nakidai Perumenei Aq Mt nakidai@disroot.org
.
.Sh CAVEATS
.Ql LibHTTPC_loadRequest
function will
destroy the buffer
while working.
It sets
0 char
on the end
of every string in
.Ql struct LibHTTPC_Request .