Skip to content

Commit c351539

Browse files
authored
docs(capi): output the hyper_version in the capi examples (#2623)
1 parent 684f2fa commit c351539

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

capi/examples/client.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ int main(int argc, char *argv[]) {
175175
hyper_io_set_read(io, read_cb);
176176
hyper_io_set_write(io, write_cb);
177177

178-
printf("http handshake ...\n");
178+
printf("http handshake (hyper v%s) ...\n", hyper_version());
179179

180180
// We need an executor generally to poll futures
181181
const hyper_executor *exec = hyper_executor_new();

capi/examples/upload.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,13 @@ static int print_each_header(void *userdata,
148148
return HYPER_ITER_CONTINUE;
149149
}
150150

151-
static void print_informational(void *userdata, hyper_response *resp) {
151+
static void print_informational(void *userdata, const hyper_response *resp) {
152152
uint16_t http_status = hyper_response_status(resp);
153153

154154
printf("\nInformational (1xx): %d\n", http_status);
155155

156-
hyper_headers *headers = hyper_response_headers(resp);
157-
hyper_headers_foreach(headers, print_each_header, NULL);
158-
printf("\n");
156+
const hyper_buf* headers = hyper_response_headers_raw(resp);
157+
write(1, hyper_buf_bytes(headers), hyper_buf_len(headers));
159158
}
160159

161160
typedef enum {
@@ -218,14 +217,15 @@ int main(int argc, char *argv[]) {
218217
hyper_io_set_read(io, read_cb);
219218
hyper_io_set_write(io, write_cb);
220219

221-
printf("http handshake ...\n");
220+
printf("http handshake (hyper v%s) ...\n", hyper_version());
222221

223222
// We need an executor generally to poll futures
224223
const hyper_executor *exec = hyper_executor_new();
225224

226225
// Prepare client options
227226
hyper_clientconn_options *opts = hyper_clientconn_options_new();
228227
hyper_clientconn_options_exec(opts, exec);
228+
hyper_clientconn_options_headers_raw(opts, 1);
229229

230230
hyper_task *handshake = hyper_clientconn_handshake(io, opts);
231231
hyper_task_set_userdata(handshake, (void *)EXAMPLE_HANDSHAKE);
@@ -275,6 +275,10 @@ int main(int argc, char *argv[]) {
275275
hyper_headers_set(req_headers, STR_ARG("host"), STR_ARG(host));
276276
hyper_headers_set(req_headers, STR_ARG("expect"), STR_ARG("100-continue"));
277277

278+
// NOTE: We aren't handling *waiting* for the 100 Continue,
279+
// the body is sent immediately. This will just print if any
280+
// informational headers are received.
281+
printf(" with expect-continue ...\n");
278282
hyper_request_on_informational(req, print_informational, NULL);
279283

280284
// Prepare the req body

0 commit comments

Comments
 (0)