Skip to end of metadata
Go to start of metadata

This section describes the examples that are related to the HTTP Client module of Micrium OS.

HTTP Client Initialization Example

Description

This is a generic example that shows how to initialize the HTTP client module. It accomplishes the following tasks:

  • Initialize the HTTP client module
  • Create a RAM disk for file exchange:
    • Store a file (index.html) to be sent to a server

Configuration

Mandatory

The following #define must be added in ex_description.h to allow other examples to initialize the HTTP Client module correctly:

#defineDescription
EX_HTTP_CLIENT_INIT_AVAILLets the upper example layer know that the HTTP Client Initialization example is present and must be called by other examples.

Optional

The following #define can be added to ex_description.h, as described in Example Applications section, to change default configuration value used by the example:

#defineDefault valueDescription
EX_HTTP_CLIENT_RAMDISK_SEC_SIZE 

512u

Specify the sector size of the RAM disk
EX_HTTP_CLIENT_RAMDISK_SEC_NBR60uSpecify the number of sector for the RAM disk
EX_HTTP_CLIENT_FILE_RAM_MEDIA_NAME

"ram_httpc"

Specify the RAM media name
EX_HTTP_CLIENT_FILE_VOL_NAME"ram_httpc"Specify  the RAM volume name
EX_HTTP_CLIENT_WRK_DIREX_HTTP_CLIENT_FILE_VOL_NAMESpecify  the working directory used by the example
EX_HTTP_CLIENT_FILE_NAME"index.html"Specify  the name of the internal file.
EX_HTTP_CLIENT_CLIENT_HOSTNAME"httpbin.org"Specify  the server host name used by the client
EX_HTTP_CLIENT_CONN_NBR_MAX5uSpecify  the maximum of active connection
EX_HTTP_CLIENT_REQ_NBR_MAX5uSpecify  the maximum of requests
EX_HTTP_CLIENT_CONN_BUF_SIZE512uSpecify  the connection buffer size
EX_HTTP_CLIENT_CFG_QUERY_STR_NBR_MAX6uSpecify  the maximum number of query string
EX_HTTP_CLIENT_CFG_QUERY_STR_KEY_LEN_MAX20uSpecify  the maximum of query string key length
EX_HTTP_CLIENT_CFG_QUERY_STR_VAL_LEN_MAX50uSpecify the maximum of query string value length
EX_HTTP_CLIENT_CFG_HDR_NBR_MAX6uSpecify the maximum of header object
EX_HTTP_CLIENT_CFG_HDR_VAL_LEN_MAX100uSpecify the maximum of header value length
EX_HTTP_CLIENT_CFG_FORM_BUF_SIZE256uSpecify the form buffer size.
EX_HTTP_CLIENT_CFG_FORM_FIELD_NBR_MAX10uSpecify the maximum nmber of form's field
EX_HTTP_CLIENT_CFG_FORM_FIELD_KEY_LEN_MAX100uSpecify the maximum of form key length
EX_HTTP_CLIENT_CFG_FORM_FIELD_VAL_LEN_MAX200uSpecify the maximum of form value length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_NAME_LEN_MAX100uSpecify the maximum of multipart name length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_FILENAME_LEN_MAX100uSpecify the maximum of multipart filename length

Location

  • /examples/net/http/client/ex_http_client.c
  • /examples/net/http/client/ex_http_client.h

API

API
Description

Ex_HTTP_Client_Init()

Initialize the HTTP Client stack for the example application.

Notes

None.

HTTP Client GET Request Examples

Description

This is a generic example that shows how to send GET request. It accomplishes the following tasks:

  • Set connection option
  • Open an HTTP connection
  • Send GET request
  • Close HTTP Connection

Configuration

Optional

The following #define can be added to ex_description.h, as described in Example Applications section, to change default configuration value used by the example:

#defineDefault valueDescription
EX_HTTP_CLIENT_RAMDISK_SEC_SIZE 

512u

Specify the sector size of the RAM disk
EX_HTTP_CLIENT_RAMDISK_SEC_NBR60uSpecify the number of sector for the RAM disk
EX_HTTP_CLIENT_FILE_RAM_MEDIA_NAME

"ram_httpc"

Specify the RAM media name
EX_HTTP_CLIENT_FILE_VOL_NAME"ram_httpc"Specify the RAM volume name
EX_HTTP_CLIENT_WRK_DIREX_HTTP_CLIENT_FILE_VOL_NAMESpecify the working directory used by the example
EX_HTTP_CLIENT_FILE_NAME"index.html"Specify the name of the internal file.
EX_HTTP_CLIENT_CLIENT_HOSTNAME"httpbin.org"Specify the server host name used by the client
EX_HTTP_CLIENT_CONN_NBR_MAX5uSpecify the maximum of active connection
EX_HTTP_CLIENT_REQ_NBR_MAX5uSpecify the maximum of requests
EX_HTTP_CLIENT_CONN_BUF_SIZE512uSpecify the connection buffer size
EX_HTTP_CLIENT_CFG_QUERY_STR_NBR_MAX6uSpecify the maximum number of query string
EX_HTTP_CLIENT_CFG_QUERY_STR_KEY_LEN_MAX20uSpecify the maximum of query string key length
EX_HTTP_CLIENT_CFG_QUERY_STR_VAL_LEN_MAX50uSpecify the maximum of query string value length
EX_HTTP_CLIENT_CFG_HDR_NBR_MAX6uSpecify the maximum of header object
EX_HTTP_CLIENT_CFG_HDR_VAL_LEN_MAX100uSpecify the maximum of header value length
EX_HTTP_CLIENT_CFG_FORM_BUF_SIZE256uSpecify the form buffer size.
EX_HTTP_CLIENT_CFG_FORM_FIELD_NBR_MAX10uSpecify the maximum nmber of form's field
EX_HTTP_CLIENT_CFG_FORM_FIELD_KEY_LEN_MAX100uSpecify the maximum of form key length
EX_HTTP_CLIENT_CFG_FORM_FIELD_VAL_LEN_MAX200uSpecify the maximum of form value length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_NAME_LEN_MAX100uSpecify the maximum of multipart name length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_FILENAME_LEN_MAX100uSpecify the maximum of multipart filename length

Location

  • /examples/net/http/client/ex_http_client_files.c
  • /examples/net/http/client/ex_http_client_files.h
  • /examples/net/http/client/ex_http_client_hooks.c
  • /examples/net/http/client/ex_http_client_hooks.h
  • /examples/net/http/client/ex_http_client.c
  • /examples/net/http/client/ex_http_client.h

API

API
Description
Ex_HTTP_Client_ReqSendGet_NoTask()Send a GET request synchronously, i.e., returns only when the transaction is completed.

Ex_HTTP_Client_ReqSendGet()

Send a GET request asynchronously. Show the callback system to be notified when the transaction is completed.

Notes

None.

HTTP Client POST Request Examples

Description

This is a generic example that shows how to send POST request. It accomplishes the following tasks:

  • Set connection option
  • Open an HTTP connection
  • Send POST request
  • Close HTTP Connection

Configuration

Optional

The following #define can be added to ex_description.h, as described in Example Applications section, to change default configuration value used by the example:

#defineDefault valueDescription
EX_HTTP_CLIENT_RAMDISK_SEC_SIZE 

512u

Specify the sector size of the RAM disk
EX_HTTP_CLIENT_RAMDISK_SEC_NBR60uSpecify the number of sector for the RAM disk
EX_HTTP_CLIENT_FILE_RAM_MEDIA_NAME

"ram_httpc"

Specify the RAM media name
EX_HTTP_CLIENT_FILE_VOL_NAME"ram_httpc"Specify the RAM volume name
EX_HTTP_CLIENT_WRK_DIREX_HTTP_CLIENT_FILE_VOL_NAMESpecify the working directory used by the example
EX_HTTP_CLIENT_FILE_NAME"index.html"Specify the name of the internal file.
EX_HTTP_CLIENT_CLIENT_HOSTNAME"httpbin.org"Specify the server host name used by the client
EX_HTTP_CLIENT_CONN_NBR_MAX5uSpecify the maximum of active connection
EX_HTTP_CLIENT_REQ_NBR_MAX5uSpecify the maximum of requests
EX_HTTP_CLIENT_CONN_BUF_SIZE512uSpecify the connection buffer size
EX_HTTP_CLIENT_CFG_QUERY_STR_NBR_MAX6uSpecify the maximum number of query string
EX_HTTP_CLIENT_CFG_QUERY_STR_KEY_LEN_MAX20uSpecify the maximum of query string key length
EX_HTTP_CLIENT_CFG_QUERY_STR_VAL_LEN_MAX50uSpecify the maximum of query string value length
EX_HTTP_CLIENT_CFG_HDR_NBR_MAX6uSpecify the maximum of header object
EX_HTTP_CLIENT_CFG_HDR_VAL_LEN_MAX100uSpecify the maximum of header value length
EX_HTTP_CLIENT_CFG_FORM_BUF_SIZE256uSpecify the form buffer size.
EX_HTTP_CLIENT_CFG_FORM_FIELD_NBR_MAX10uSpecify the maximum nmber of form's field
EX_HTTP_CLIENT_CFG_FORM_FIELD_KEY_LEN_MAX100uSpecify the maximum of form key length
EX_HTTP_CLIENT_CFG_FORM_FIELD_VAL_LEN_MAX200uSpecify the maximum of form value length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_NAME_LEN_MAX100uSpecify the maximum of multipart name length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_FILENAME_LEN_MAX100uSpecify the maximum of multipart filename length

Location

  • /examples/net/http/client/ex_http_client_files.c
  • /examples/net/http/client/ex_http_client_files.h
  • /examples/net/http/client/ex_http_client_hooks.c
  • /examples/net/http/client/ex_http_client_hooks.h
  • /examples/net/http/client/ex_http_client.c
  • /examples/net/http/client/ex_http_client.h

API

API
Description
Ex_HTTP_Client_ReqSendPost()Send a POST request with a pre-formatted form as body.

Ex_HTTP_Client_ReqSendAppForm()

Send an Application type form.

Ex_HTTP_Client_ReqSendMultipartForm()

Send a multipart type form.

Notes

None.

HTTP Client PUT Request Examples

Description

This is a generic example that shows how to send PUT request. It accomplishes the following tasks:

  • Set connection option
  • Open an HTTP connection
  • Send PUT request
  • Close HTTP Connection

Configuration

Optional

The following #define can be added to ex_description.h, as described in Example Applications section, to change default configuration value used by the example:

#defineDefault valueDescription
EX_HTTP_CLIENT_RAMDISK_SEC_SIZE 

512u

Specify the sector size of the RAM disk
EX_HTTP_CLIENT_RAMDISK_SEC_NBR60uSpecify the number of sector for the RAM disk
EX_HTTP_CLIENT_FILE_RAM_MEDIA_NAME

"ram_httpc"

Specify the RAM media name
EX_HTTP_CLIENT_FILE_VOL_NAME"ram_httpc"Specify the RAM volume name
EX_HTTP_CLIENT_WRK_DIREX_HTTP_CLIENT_FILE_VOL_NAMESpecify the working directory used by the example
EX_HTTP_CLIENT_FILE_NAME"index.html"Specify the name of the internal file.
EX_HTTP_CLIENT_CLIENT_HOSTNAME"httpbin.org"Specify the server host name used by the client
EX_HTTP_CLIENT_CONN_NBR_MAX5uSpecify the maximum of active connection
EX_HTTP_CLIENT_REQ_NBR_MAX5uSpecify the maximum of requests
EX_HTTP_CLIENT_CONN_BUF_SIZE512uSpecify the connection buffer size
EX_HTTP_CLIENT_CFG_QUERY_STR_NBR_MAX6uSpecify the maximum number of query string
EX_HTTP_CLIENT_CFG_QUERY_STR_KEY_LEN_MAX20uSpecify the maximum of query string key length
EX_HTTP_CLIENT_CFG_QUERY_STR_VAL_LEN_MAX50uSpecify the maximum of query string value length
EX_HTTP_CLIENT_CFG_HDR_NBR_MAX6uSpecify the maximum of header object
EX_HTTP_CLIENT_CFG_HDR_VAL_LEN_MAX100uSpecify the maximum of header value length
EX_HTTP_CLIENT_CFG_FORM_BUF_SIZE256uSpecify the form buffer size.
EX_HTTP_CLIENT_CFG_FORM_FIELD_NBR_MAX10uSpecify the maximum nmber of form's field
EX_HTTP_CLIENT_CFG_FORM_FIELD_KEY_LEN_MAX100uSpecify the maximum of form key length
EX_HTTP_CLIENT_CFG_FORM_FIELD_VAL_LEN_MAX200uSpecify the maximum of form value length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_NAME_LEN_MAX100uSpecify the maximum of multipart name length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_FILENAME_LEN_MAX100uSpecify the maximum of multipart filename length

Location

  • /examples/net/http/client/ex_http_client_files.c
  • /examples/net/http/client/ex_http_client_files.h
  • /examples/net/http/client/ex_http_client_hooks.c
  • /examples/net/http/client/ex_http_client_hooks.h
  • /examples/net/http/client/ex_http_client.c
  • /examples/net/http/client/ex_http_client.h

API

API
Description
Ex_HTTP_Client_ReqSendPut()Send PUT request.

Notes

None.

HTTP Client Persistent Connection Examples

Description

This is a generic example that shows how to send multiple GET request on the same connection. It accomplishes the following tasks:

  • Set connection option
  • Open an HTTP connection
  • Send GET request #1
  • Send GET request #2
  • Close HTTP Connection

Configuration

Optional

The following #define can be added to ex_description.h, as described in Example Applications section, to change default configuration value used by the example:

#defineDefault valueDescription
EX_HTTP_CLIENT_RAMDISK_SEC_SIZE 

512u

Specify the sector size of the RAM disk
EX_HTTP_CLIENT_RAMDISK_SEC_NBR60uSpecify the number of sector for the RAM disk
EX_HTTP_CLIENT_FILE_RAM_MEDIA_NAME

"ram_httpc"

Specify the RAM media name
EX_HTTP_CLIENT_FILE_VOL_NAME"ram_httpc"Specify the RAM volume name
EX_HTTP_CLIENT_WRK_DIREX_HTTP_CLIENT_FILE_VOL_NAMESpecify the working directory used by the example
EX_HTTP_CLIENT_FILE_NAME"index.html"Specify the name of the internal file.
EX_HTTP_CLIENT_CLIENT_HOSTNAME"httpbin.org"Specify the server host name used by the client
EX_HTTP_CLIENT_CONN_NBR_MAX5uSpecify the maximum of active connection
EX_HTTP_CLIENT_REQ_NBR_MAX5uSpecify the maximum of requests
EX_HTTP_CLIENT_CONN_BUF_SIZE512uSpecify the connection buffer size
EX_HTTP_CLIENT_CFG_QUERY_STR_NBR_MAX6uSpecify the maximum number of query string
EX_HTTP_CLIENT_CFG_QUERY_STR_KEY_LEN_MAX20uSpecify the maximum of query string key length
EX_HTTP_CLIENT_CFG_QUERY_STR_VAL_LEN_MAX50uSpecify the maximum of query string value length
EX_HTTP_CLIENT_CFG_HDR_NBR_MAX6uSpecify the maximum of header object
EX_HTTP_CLIENT_CFG_HDR_VAL_LEN_MAX100uSpecify the maximum of header value length
EX_HTTP_CLIENT_CFG_FORM_BUF_SIZE256uSpecify the form buffer size.
EX_HTTP_CLIENT_CFG_FORM_FIELD_NBR_MAX10uSpecify the maximum nmber of form's field
EX_HTTP_CLIENT_CFG_FORM_FIELD_KEY_LEN_MAX100uSpecify the maximum of form key length
EX_HTTP_CLIENT_CFG_FORM_FIELD_VAL_LEN_MAX200uSpecify the maximum of form value length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_NAME_LEN_MAX100uSpecify the maximum of multipart name length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_FILENAME_LEN_MAX100uSpecify the maximum of multipart filename length

Location

  • /examples/net/http/client/ex_http_client_files.c
  • /examples/net/http/client/ex_http_client_files.h
  • /examples/net/http/client/ex_http_client_hooks.c
  • /examples/net/http/client/ex_http_client_hooks.h
  • /examples/net/http/client/ex_http_client.c
  • /examples/net/http/client/ex_http_client.h

API

API
Description
Ex_HTTP_Client_PersistentConn()Send multiple requests on same connection.

Notes

None.

HTTP Client Multi-connection Examples

Description

This is a generic example that shows how to open multiple connections and how to send requests in parallel. It accomplishes the following tasks:

  • Set connection #1 option
  • Set connection #2 option
  • Open an HTTP connection #1
  • Open an HTTP connection #2
  • Send GET request #1
  • Send GET request #2

Configuration

Optional

The following #define can be added to ex_description.h, as described in Example Applications section, to change default configuration value used by the example:

#defineDefault valueDescription
EX_HTTP_CLIENT_RAMDISK_SEC_SIZE 

512u

Specify the sector size of the RAM disk
EX_HTTP_CLIENT_RAMDISK_SEC_NBR60uSpecify the number of sector for the RAM disk
EX_HTTP_CLIENT_FILE_RAM_MEDIA_NAME

"ram_httpc"

Specify the RAM media name
EX_HTTP_CLIENT_FILE_VOL_NAME"ram_httpc"Specify the RAM volume name
EX_HTTP_CLIENT_WRK_DIREX_HTTP_CLIENT_FILE_VOL_NAMESpecify the working directory used by the example
EX_HTTP_CLIENT_FILE_NAME"index.html"Specify the name of the internal file.
EX_HTTP_CLIENT_CLIENT_HOSTNAME"httpbin.org"Specify the server host name used by the client
EX_HTTP_CLIENT_CONN_NBR_MAX5uSpecify the maximum of active connection
EX_HTTP_CLIENT_REQ_NBR_MAX5uSpecify the maximum of requests
EX_HTTP_CLIENT_CONN_BUF_SIZE512uSpecify the connection buffer size
EX_HTTP_CLIENT_CFG_QUERY_STR_NBR_MAX6uSpecify the maximum number of query string
EX_HTTP_CLIENT_CFG_QUERY_STR_KEY_LEN_MAX20uSpecify the maximum of query string key length
EX_HTTP_CLIENT_CFG_QUERY_STR_VAL_LEN_MAX50uSpecify the maximum of query string value length
EX_HTTP_CLIENT_CFG_HDR_NBR_MAX6uSpecify the maximum of header object
EX_HTTP_CLIENT_CFG_HDR_VAL_LEN_MAX100uSpecify the maximum of header value length
EX_HTTP_CLIENT_CFG_FORM_BUF_SIZE256uSpecify the form buffer size.
EX_HTTP_CLIENT_CFG_FORM_FIELD_NBR_MAX10uSpecify the maximum number of form's field
EX_HTTP_CLIENT_CFG_FORM_FIELD_KEY_LEN_MAX100uSpecify the maximum of form key length
EX_HTTP_CLIENT_CFG_FORM_FIELD_VAL_LEN_MAX200uSpecify the maximum of form value length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_NAME_LEN_MAX100uSpecify the maximum of multipart name length
EX_HTTP_CLIENT_CFG_FORM_MULTIPART_FILENAME_LEN_MAX100uSpecify the maximum of multipart filename length

Location

  • /examples/net/http/client/ex_http_client_files.c
  • /examples/net/http/client/ex_http_client_files.h
  • /examples/net/http/client/ex_http_client_hooks.c
  • /examples/net/http/client/ex_http_client_hooks.h
  • /examples/net/http/client/ex_http_client.c
  • /examples/net/http/client/ex_http_client.h

API

API
Description
Ex_HTTP_Client_MultiConn()Open multiple Connections to send HTTP requests in parallel.

Notes

None.