Skip to content

Commit c5d686a

Browse files
committed
samples: net: http_client: HTTP client sample application
Simple HTTP client sample that connects to HTTP server and does GET and POST requests. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent ef9d61d commit c5d686a

File tree

6 files changed

+412
-0
lines changed

6 files changed

+412
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.13.1)
4+
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
5+
project(http_client)
6+
7+
FILE(GLOB app_sources src/*.c)
8+
target_sources(app PRIVATE ${app_sources})
9+
10+
set(gen_dir ${ZEPHYR_BINARY_DIR}/include/generated/)
11+
12+
generate_inc_file_for_target(
13+
app
14+
src/echo-apps-cert.der
15+
${gen_dir}/echo-apps-cert.der.inc
16+
)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Networking config
2+
CONFIG_NETWORKING=y
3+
CONFIG_NET_IPV4=y
4+
CONFIG_NET_IPV6=y
5+
CONFIG_NET_TCP=y
6+
CONFIG_NET_SHELL=y
7+
8+
# Sockets
9+
CONFIG_NET_SOCKETS=y
10+
CONFIG_NET_SOCKETS_POSIX_NAMES=y
11+
CONFIG_NET_SOCKETS_POLL_MAX=4
12+
13+
# Network driver config
14+
CONFIG_TEST_RANDOM_GENERATOR=y
15+
16+
# Network address config
17+
CONFIG_NET_CONFIG_SETTINGS=y
18+
CONFIG_NET_CONFIG_NEED_IPV4=y
19+
CONFIG_NET_CONFIG_NEED_IPV6=y
20+
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
21+
CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
22+
# Address of HTTP IPv4 server
23+
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
24+
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
25+
# Address of HTTP IPv6 server
26+
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
27+
28+
# HTTP
29+
CONFIG_HTTP_CLIENT=y
30+
31+
# Network debug config
32+
CONFIG_LOG=y
33+
CONFIG_LOG_IMMEDIATE=y
34+
CONFIG_NET_LOG=y
35+
CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=n
36+
CONFIG_NET_HTTP_LOG_LEVEL_DBG=y
37+
38+
CONFIG_MAIN_STACK_SIZE=2048
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
common:
2+
tags: net http http_client
3+
sample:
4+
description: HTTP client sample
5+
name: http_client
6+
tests:
7+
sample.net.sockets.http_client:
8+
harness: net
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#define CA_CERTIFICATE_TAG 1
8+
9+
#define TLS_PEER_HOSTNAME "localhost"
10+
11+
/* This is the same cert as what is found in net-tools/echo-apps-cert.pem file
12+
*/
13+
static const unsigned char ca_certificate[] = {
14+
#include "echo-apps-cert.der.inc"
15+
};
767 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)