docs(capi): output the hyper_version in the capi examples (#2623)
This commit is contained in:
@@ -175,7 +175,7 @@ int main(int argc, char *argv[]) {
|
|||||||
hyper_io_set_read(io, read_cb);
|
hyper_io_set_read(io, read_cb);
|
||||||
hyper_io_set_write(io, write_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
|
// We need an executor generally to poll futures
|
||||||
const hyper_executor *exec = hyper_executor_new();
|
const hyper_executor *exec = hyper_executor_new();
|
||||||
|
|||||||
@@ -148,14 +148,13 @@ static int print_each_header(void *userdata,
|
|||||||
return HYPER_ITER_CONTINUE;
|
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);
|
uint16_t http_status = hyper_response_status(resp);
|
||||||
|
|
||||||
printf("\nInformational (1xx): %d\n", http_status);
|
printf("\nInformational (1xx): %d\n", http_status);
|
||||||
|
|
||||||
hyper_headers *headers = hyper_response_headers(resp);
|
const hyper_buf* headers = hyper_response_headers_raw(resp);
|
||||||
hyper_headers_foreach(headers, print_each_header, NULL);
|
write(1, hyper_buf_bytes(headers), hyper_buf_len(headers));
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -218,7 +217,7 @@ int main(int argc, char *argv[]) {
|
|||||||
hyper_io_set_read(io, read_cb);
|
hyper_io_set_read(io, read_cb);
|
||||||
hyper_io_set_write(io, write_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
|
// We need an executor generally to poll futures
|
||||||
const hyper_executor *exec = hyper_executor_new();
|
const hyper_executor *exec = hyper_executor_new();
|
||||||
@@ -226,6 +225,7 @@ int main(int argc, char *argv[]) {
|
|||||||
// Prepare client options
|
// Prepare client options
|
||||||
hyper_clientconn_options *opts = hyper_clientconn_options_new();
|
hyper_clientconn_options *opts = hyper_clientconn_options_new();
|
||||||
hyper_clientconn_options_exec(opts, exec);
|
hyper_clientconn_options_exec(opts, exec);
|
||||||
|
hyper_clientconn_options_headers_raw(opts, 1);
|
||||||
|
|
||||||
hyper_task *handshake = hyper_clientconn_handshake(io, opts);
|
hyper_task *handshake = hyper_clientconn_handshake(io, opts);
|
||||||
hyper_task_set_userdata(handshake, (void *)EXAMPLE_HANDSHAKE);
|
hyper_task_set_userdata(handshake, (void *)EXAMPLE_HANDSHAKE);
|
||||||
@@ -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("host"), STR_ARG(host));
|
||||||
hyper_headers_set(req_headers, STR_ARG("expect"), STR_ARG("100-continue"));
|
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);
|
hyper_request_on_informational(req, print_informational, NULL);
|
||||||
|
|
||||||
// Prepare the req body
|
// Prepare the req body
|
||||||
|
|||||||
Reference in New Issue
Block a user