1ZHTTP_REQUEST(3)                  CZMQ Manual                 ZHTTP_REQUEST(3)
2
3
4

NAME

6       zhttp_request - Class for zhttp server request.
7

SYNOPSIS

9       //  This is a draft class, and may change without notice. It is disabled in
10       //  stable builds by default. If you use this in applications, please ask
11       //  for it to be pushed to stable state. Use --enable-drafts to enable.
12       #ifdef CZMQ_BUILD_DRAFT_API
13       //  *** Draft method, for development use, may change without warning ***
14       //  Create a new http request.
15       CZMQ_EXPORT zhttp_request_t *
16           zhttp_request_new (void);
17
18       //  *** Draft method, for development use, may change without warning ***
19       //  Destroy an http request.
20       CZMQ_EXPORT void
21           zhttp_request_destroy (zhttp_request_t **self_p);
22
23       //  *** Draft method, for development use, may change without warning ***
24       //  Receive a new request from zhttp_server.
25       //  Return the underlying connection if successful, to be used when calling zhttp_response_send.
26       CZMQ_EXPORT void *
27           zhttp_request_recv (zhttp_request_t *self, zsock_t *sock);
28
29       //  *** Draft method, for development use, may change without warning ***
30       //  Send a request to zhttp_client.
31       //  Url and the request path will be concatenated.
32       //  This behavior is useful for url rewrite and reverse proxy.
33       //
34       //  Send also allow two user provided arguments which will be returned with the response.
35       //  The reason for two, is to be able to pass around the server connection when forwarding requests or both a callback function and an arg.
36       CZMQ_EXPORT int
37           zhttp_request_send (zhttp_request_t *self, zhttp_client_t *client, int timeout, void *arg, void *arg2);
38
39       //  *** Draft method, for development use, may change without warning ***
40       //  Get the request method
41       CZMQ_EXPORT const char *
42           zhttp_request_method (zhttp_request_t *self);
43
44       //  *** Draft method, for development use, may change without warning ***
45       //  Set the request method
46       CZMQ_EXPORT void
47           zhttp_request_set_method (zhttp_request_t *self, const char *method);
48
49       //  *** Draft method, for development use, may change without warning ***
50       //  Get the request url.
51       //  When receiving a request from http server this is only the path part of the url.
52       CZMQ_EXPORT const char *
53           zhttp_request_url (zhttp_request_t *self);
54
55       //  *** Draft method, for development use, may change without warning ***
56       //  Set the request url
57       //  When sending a request to http client this should be full url.
58       CZMQ_EXPORT void
59           zhttp_request_set_url (zhttp_request_t *self, const char *url);
60
61       //  *** Draft method, for development use, may change without warning ***
62       //  Get the request content type
63       CZMQ_EXPORT const char *
64           zhttp_request_content_type (zhttp_request_t *self);
65
66       //  *** Draft method, for development use, may change without warning ***
67       //  Set the request content type
68       CZMQ_EXPORT void
69           zhttp_request_set_content_type (zhttp_request_t *self, const char *content_type);
70
71       //  *** Draft method, for development use, may change without warning ***
72       //  Get the content length of the request
73       CZMQ_EXPORT size_t
74           zhttp_request_content_length (zhttp_request_t *self);
75
76       //  *** Draft method, for development use, may change without warning ***
77       //  Get the headers of the request
78       CZMQ_EXPORT zhash_t *
79           zhttp_request_headers (zhttp_request_t *self);
80
81       //  *** Draft method, for development use, may change without warning ***
82       //  Get the content of the request.
83       CZMQ_EXPORT const char *
84           zhttp_request_content (zhttp_request_t *self);
85
86       //  *** Draft method, for development use, may change without warning ***
87       //  Get the content of the request.
88       //  Caller owns return value and must destroy it when done.
89       CZMQ_EXPORT char *
90           zhttp_request_get_content (zhttp_request_t *self);
91
92       //  *** Draft method, for development use, may change without warning ***
93       //  Set the content of the request.
94       //  Content must by dynamically allocated string.
95       //  Takes ownership of the content.
96       CZMQ_EXPORT void
97           zhttp_request_set_content (zhttp_request_t *self, char **content);
98
99       //  *** Draft method, for development use, may change without warning ***
100       //  Set the content of the request..
101       //  The content is assumed to be constant-memory and will therefore not be copied or deallocated in any way.
102       CZMQ_EXPORT void
103           zhttp_request_set_content_const (zhttp_request_t *self, const char *content);
104
105       //  *** Draft method, for development use, may change without warning ***
106       //  Set the content to NULL
107       CZMQ_EXPORT void
108           zhttp_request_reset_content (zhttp_request_t *self);
109
110       //  *** Draft method, for development use, may change without warning ***
111       //  Match the path of the request.
112       //  Support wildcards with '%s' symbol inside the match string.
113       //  Matching wildcards until the next '/', '?' or '\0'.
114       //  On successful match the variadic arguments will be filled with the matching strings.
115       //  On successful match the method is modifying the url field and break it into substrings.
116       //  If you need to use the url, do it before matching or take a copy.
117       //
118       //  User must not free the variadic arguments as they are part of the url.
119       //
120       //  To use the percent symbol, just double it, e.g "%%something".
121       //
122       //  Example:
123       //  if (zhttp_request_match (request, "POST", "/send/%s/%s", &name, &id))
124       CZMQ_EXPORT bool
125           zhttp_request_match (zhttp_request_t *self, const char *method, const char *path, ...);
126
127       //  *** Draft method, for development use, may change without warning ***
128       //  Self test of this class.
129       CZMQ_EXPORT void
130           zhttp_request_test (bool verbose);
131
132       #endif // CZMQ_BUILD_DRAFT_API
133       Please add '@interface' section in './../src/zhttp_request.c'.
134

DESCRIPTION

136       zhttp_request - zhttp server request. Class can be reused.
137
138       Please add @discuss section in ./../src/zhttp_request.c.
139

EXAMPLE

141       From zhttp_request_test method.
142
143           Please add '@selftest' section in './../src/zhttp_request.c'.
144
145

AUTHORS

147       The czmq manual was written by the authors in the AUTHORS file.
148

RESOURCES

150       Main web site:
151
152       Report bugs to the email <zeromq-dev@lists.zeromq.org[1]>
153
155       Copyright (c) the Contributors as noted in the AUTHORS file. This file
156       is part of CZMQ, the high-level C binding for 0MQ:
157       http://czmq.zeromq.org. This Source Code Form is subject to the terms
158       of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
159       distributed with this file, You can obtain one at
160       http://mozilla.org/MPL/2.0/. LICENSE included with the czmq
161       distribution.
162

NOTES

164        1. zeromq-dev@lists.zeromq.org
165           mailto:zeromq-dev@lists.zeromq.org
166
167
168
169CZMQ 4.2.1                        07/20/2022                  ZHTTP_REQUEST(3)
Impressum