network/http_methods/http_get.c
/*
* EVALUATION AND USE OF THIS SOFTWARE IS SUBJECT TO THE TERMS AND
* CONDITIONS OF THE CONTROLLING LICENSE AGREEMENT FOUND AT LICENSE.md
* IN THIS SDK. IF YOU DO NOT AGREE TO THE LICENSE TERMS AND CONDITIONS,
* PLEASE RETURN ALL SOURCE FILES TO SILICON LABORATORIES.
* (c) Copyright 2018, Silicon Laboratories Inc. All rights reserved.
*/
#include "common.h"
/*************************************************************************************************/
void http_get_example(void)
{
GOS_LOG("Running HTTP: GET %s", bin_url);
gos_result_t result;
gos_handle_t handle;
gos_http_response_t response;
gos_http_request_t request =
{
.method = GOS_HTTP_GET,
.url = bin_url,
};
GOS_LOG("Issuing request ... ");
{
GOS_LOG("Request failed: %d", result);
return;
}
GOS_LOG("Adding custom header ... ");
{
GOS_LOG("Failed to add header: %d", result);
return;
}
GOS_LOG("Receiving response ... ");
{
GOS_LOG("Response failed: %d", result);
return;
}
if (response.content_length > 0)
{
uint32_t bytes_read;
char buffer[256];
GOS_LOG("Response:");
{
GOS_LOG("Failed to read response: %d", result);
return;
}
buffer[bytes_read] = 0;
GOS_LOG("%s", buffer);
}
gos_http_close(handle);
GOS_LOG("Success\r\n");
}