Replace http_/HTTP_ prefixes with chttp_/CHTTP_
This commit is contained in:
@@ -4,37 +4,37 @@ int main(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
HTTP_Client client;
|
||||
ret = http_client_init(&client);
|
||||
CHTTP_Client client;
|
||||
ret = chttp_client_init(&client);
|
||||
if (ret < 0) {
|
||||
printf("Couldn't initialize client (%s)\n", http_strerror(ret));
|
||||
printf("Couldn't initialize client (%s)\n", chttp_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
HTTP_RequestBuilder builder = http_client_get_builder(&client);
|
||||
CHTTP_RequestBuilder builder = chttp_client_get_builder(&client);
|
||||
|
||||
http_request_builder_method(builder, HTTP_METHOD_GET);
|
||||
http_request_builder_target(builder, HTTP_STR("http://coz.is"));
|
||||
http_request_builder_header(builder, HTTP_STR("Greeting: Hello from the cHTTP example!"));
|
||||
chttp_request_builder_method(builder, CHTTP_METHOD_GET);
|
||||
chttp_request_builder_target(builder, CHTTP_STR("http://coz.is"));
|
||||
chttp_request_builder_header(builder, CHTTP_STR("Greeting: Hello from the cHTTP example!"));
|
||||
|
||||
ret = http_request_builder_send(builder);
|
||||
ret = chttp_request_builder_send(builder);
|
||||
if (ret < 0) {
|
||||
printf("Couldn't build request (%s)\n", http_strerror(ret));
|
||||
printf("Couldn't build request (%s)\n", chttp_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result;
|
||||
void *user;
|
||||
HTTP_Response *response;
|
||||
http_client_wait_response(&client, &result, &user, &response);
|
||||
CHTTP_Response *response;
|
||||
chttp_client_wait_response(&client, &result, &user, &response);
|
||||
|
||||
if (result == HTTP_OK) {
|
||||
if (result == CHTTP_OK) {
|
||||
printf("Received %d bytes\n", response->body.len);
|
||||
} else {
|
||||
printf("Couldn't receive response (%s)\n", http_strerror(result));
|
||||
printf("Couldn't receive response (%s)\n", chttp_strerror(result));
|
||||
}
|
||||
|
||||
http_free_response(response);
|
||||
http_client_free(&client);
|
||||
chttp_free_response(response);
|
||||
chttp_client_free(&client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user