Skip to content

Commit 865393d

Browse files
JorgeGzmjerpelea
authored andcommitted
system/curl: add a small curl-like HTTP client command
Add the "curl" NSH command: a command-line HTTP client built on top of the netutils webclient library. It implements a subset of the real curl options: GET and POST (and other methods via -X), custom request headers (-H), a raw request body (-d, including -d @file), multipart/form-data file uploads (-F name=@file), saving the response body to a file (-o) and verbose output (-v). HTTP only (no HTTPS). Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
1 parent 98f683d commit 865393d

5 files changed

Lines changed: 996 additions & 0 deletions

File tree

system/curl/CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ##############################################################################
2+
# apps/system/curl/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_SYSTEM_CURL)
24+
nuttx_add_application(
25+
NAME
26+
${CONFIG_SYSTEM_CURL_PROGNAME}
27+
SRCS
28+
curl_main.c
29+
STACKSIZE
30+
${CONFIG_SYSTEM_CURL_STACKSIZE}
31+
PRIORITY
32+
${CONFIG_SYSTEM_CURL_PRIORITY})
33+
endif()

system/curl/Kconfig

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config SYSTEM_CURL
7+
tristate "curl HTTP command"
8+
default n
9+
depends on NETUTILS_WEBCLIENT
10+
---help---
11+
Enable the "curl" command: a small command-line HTTP client
12+
supporting GET and POST (and other methods via -X), custom
13+
headers (-H), a raw request body (-d, including -d @file) and
14+
multipart/form-data file uploads (-F name=@file), built on top
15+
of the netutils webclient library. HTTP only (no HTTPS).
16+
17+
if SYSTEM_CURL
18+
19+
config SYSTEM_CURL_PROGNAME
20+
string "Program name"
21+
default "curl"
22+
---help---
23+
This is the name of the program that will be used when the
24+
NSH ELF program is installed.
25+
26+
config SYSTEM_CURL_PRIORITY
27+
int "curl task priority"
28+
default 100
29+
30+
config SYSTEM_CURL_STACKSIZE
31+
int "curl stack size"
32+
default DEFAULT_TASK_STACKSIZE
33+
34+
config SYSTEM_CURL_BUFFERSIZE
35+
int "curl transfer buffer size"
36+
default 512
37+
---help---
38+
Size of the buffer used to hold the request/response headers and
39+
to stream body data. It must be large enough to hold the whole
40+
request header line and the whole response header.
41+
42+
endif

system/curl/Make.defs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# apps/system/curl/Make.defs
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
ifneq ($(CONFIG_SYSTEM_CURL),)
24+
CONFIGURED_APPS += $(APPDIR)/system/curl
25+
endif

system/curl/Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
############################################################################
2+
# apps/system/curl/Makefile
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
include $(APPDIR)/Make.defs
24+
25+
# curl built-in application info
26+
27+
PROGNAME = $(CONFIG_SYSTEM_CURL_PROGNAME)
28+
PRIORITY = $(CONFIG_SYSTEM_CURL_PRIORITY)
29+
STACKSIZE = $(CONFIG_SYSTEM_CURL_STACKSIZE)
30+
MODULE = $(CONFIG_SYSTEM_CURL)
31+
32+
# curl command
33+
34+
MAINSRC = curl_main.c
35+
36+
include $(APPDIR)/Application.mk

0 commit comments

Comments
 (0)