Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(capi): output the hyper_version in the capi examples #2623

Merged
merged 1 commit into from Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion capi/examples/client.c
Expand Up @@ -175,7 +175,7 @@ int main(int argc, char *argv[]) {
hyper_io_set_read(io, read_cb);
hyper_io_set_write(io, write_cb);

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

// We need an executor generally to poll futures
const hyper_executor *exec = hyper_executor_new();
Expand Down
14 changes: 9 additions & 5 deletions capi/examples/upload.c
Expand Up @@ -148,14 +148,13 @@ static int print_each_header(void *userdata,
return HYPER_ITER_CONTINUE;
}

static void print_informational(void *userdata, hyper_response *resp) {
static void print_informational(void *userdata, const hyper_response *resp) {
uint16_t http_status = hyper_response_status(resp);

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

hyper_headers *headers = hyper_response_headers(resp);
hyper_headers_foreach(headers, print_each_header, NULL);
printf("\n");
const hyper_buf* headers = hyper_response_headers_raw(resp);
write(1, hyper_buf_bytes(headers), hyper_buf_len(headers));
}

typedef enum {
Expand Down Expand Up @@ -218,14 +217,15 @@ int main(int argc, char *argv[]) {
hyper_io_set_read(io, read_cb);
hyper_io_set_write(io, write_cb);

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

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

// Prepare client options
hyper_clientconn_options *opts = hyper_clientconn_options_new();
hyper_clientconn_options_exec(opts, exec);
hyper_clientconn_options_headers_raw(opts, 1);

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

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

// Prepare the req body
Expand Down