Scott Vincent / mbed-http

Files at this revision

API Documentation at this revision

Comitter:
jump_man
Date:
Thu Feb 18 20:27:07 2021 +0000
Parent:
34:6daf67a96a91
Commit message:
Update.;

Changed in this revision

LICENSE Show diff for this revision Revisions of this file
README.md Show diff for this revision Revisions of this file
TESTS/COMMON/test_setup.h Show diff for this revision Revisions of this file
TESTS/tests/integration/main.cpp Show diff for this revision Revisions of this file
img/root-ca-selection.png Show diff for this revision Revisions of this file
mbed_lib.json Show diff for this revision Revisions of this file
--- a/LICENSE	Fri Jan 04 13:27:32 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,191 +0,0 @@
-Apache License
-Version 2.0, January 2004
-http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
-"License" shall mean the terms and conditions for use, reproduction, and
-distribution as defined by Sections 1 through 9 of this document.
-
-"Licensor" shall mean the copyright owner or entity authorized by the copyright
-owner that is granting the License.
-
-"Legal Entity" shall mean the union of the acting entity and all other entities
-that control, are controlled by, or are under common control with that entity.
-For the purposes of this definition, "control" means (i) the power, direct or
-indirect, to cause the direction or management of such entity, whether by
-contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
-outstanding shares, or (iii) beneficial ownership of such entity.
-
-"You" (or "Your") shall mean an individual or Legal Entity exercising
-permissions granted by this License.
-
-"Source" form shall mean the preferred form for making modifications, including
-but not limited to software source code, documentation source, and configuration
-files.
-
-"Object" form shall mean any form resulting from mechanical transformation or
-translation of a Source form, including but not limited to compiled object code,
-generated documentation, and conversions to other media types.
-
-"Work" shall mean the work of authorship, whether in Source or Object form, made
-available under the License, as indicated by a copyright notice that is included
-in or attached to the work (an example is provided in the Appendix below).
-
-"Derivative Works" shall mean any work, whether in Source or Object form, that
-is based on (or derived from) the Work and for which the editorial revisions,
-annotations, elaborations, or other modifications represent, as a whole, an
-original work of authorship. For the purposes of this License, Derivative Works
-shall not include works that remain separable from, or merely link (or bind by
-name) to the interfaces of, the Work and Derivative Works thereof.
-
-"Contribution" shall mean any work of authorship, including the original version
-of the Work and any modifications or additions to that Work or Derivative Works
-thereof, that is intentionally submitted to Licensor for inclusion in the Work
-by the copyright owner or by an individual or Legal Entity authorized to submit
-on behalf of the copyright owner. For the purposes of this definition,
-"submitted" means any form of electronic, verbal, or written communication sent
-to the Licensor or its representatives, including but not limited to
-communication on electronic mailing lists, source code control systems, and
-issue tracking systems that are managed by, or on behalf of, the Licensor for
-the purpose of discussing and improving the Work, but excluding communication
-that is conspicuously marked or otherwise designated in writing by the copyright
-owner as "Not a Contribution."
-
-"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
-of whom a Contribution has been received by Licensor and subsequently
-incorporated within the Work.
-
-2. Grant of Copyright License.
-
-Subject to the terms and conditions of this License, each Contributor hereby
-grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
-irrevocable copyright license to reproduce, prepare Derivative Works of,
-publicly display, publicly perform, sublicense, and distribute the Work and such
-Derivative Works in Source or Object form.
-
-3. Grant of Patent License.
-
-Subject to the terms and conditions of this License, each Contributor hereby
-grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
-irrevocable (except as stated in this section) patent license to make, have
-made, use, offer to sell, sell, import, and otherwise transfer the Work, where
-such license applies only to those patent claims licensable by such Contributor
-that are necessarily infringed by their Contribution(s) alone or by combination
-of their Contribution(s) with the Work to which such Contribution(s) was
-submitted. If You institute patent litigation against any entity (including a
-cross-claim or counterclaim in a lawsuit) alleging that the Work or a
-Contribution incorporated within the Work constitutes direct or contributory
-patent infringement, then any patent licenses granted to You under this License
-for that Work shall terminate as of the date such litigation is filed.
-
-4. Redistribution.
-
-You may reproduce and distribute copies of the Work or Derivative Works thereof
-in any medium, with or without modifications, and in Source or Object form,
-provided that You meet the following conditions:
-
-You must give any other recipients of the Work or Derivative Works a copy of
-this License; and
-You must cause any modified files to carry prominent notices stating that You
-changed the files; and
-You must retain, in the Source form of any Derivative Works that You distribute,
-all copyright, patent, trademark, and attribution notices from the Source form
-of the Work, excluding those notices that do not pertain to any part of the
-Derivative Works; and
-If the Work includes a "NOTICE" text file as part of its distribution, then any
-Derivative Works that You distribute must include a readable copy of the
-attribution notices contained within such NOTICE file, excluding those notices
-that do not pertain to any part of the Derivative Works, in at least one of the
-following places: within a NOTICE text file distributed as part of the
-Derivative Works; within the Source form or documentation, if provided along
-with the Derivative Works; or, within a display generated by the Derivative
-Works, if and wherever such third-party notices normally appear. The contents of
-the NOTICE file are for informational purposes only and do not modify the
-License. You may add Your own attribution notices within Derivative Works that
-You distribute, alongside or as an addendum to the NOTICE text from the Work,
-provided that such additional attribution notices cannot be construed as
-modifying the License.
-You may add Your own copyright statement to Your modifications and may provide
-additional or different license terms and conditions for use, reproduction, or
-distribution of Your modifications, or for any such Derivative Works as a whole,
-provided Your use, reproduction, and distribution of the Work otherwise complies
-with the conditions stated in this License.
-
-5. Submission of Contributions.
-
-Unless You explicitly state otherwise, any Contribution intentionally submitted
-for inclusion in the Work by You to the Licensor shall be under the terms and
-conditions of this License, without any additional terms or conditions.
-Notwithstanding the above, nothing herein shall supersede or modify the terms of
-any separate license agreement you may have executed with Licensor regarding
-such Contributions.
-
-6. Trademarks.
-
-This License does not grant permission to use the trade names, trademarks,
-service marks, or product names of the Licensor, except as required for
-reasonable and customary use in describing the origin of the Work and
-reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty.
-
-Unless required by applicable law or agreed to in writing, Licensor provides the
-Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
-including, without limitation, any warranties or conditions of TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
-solely responsible for determining the appropriateness of using or
-redistributing the Work and assume any risks associated with Your exercise of
-permissions under this License.
-
-8. Limitation of Liability.
-
-In no event and under no legal theory, whether in tort (including negligence),
-contract, or otherwise, unless required by applicable law (such as deliberate
-and grossly negligent acts) or agreed to in writing, shall any Contributor be
-liable to You for damages, including any direct, indirect, special, incidental,
-or consequential damages of any character arising as a result of this License or
-out of the use or inability to use the Work (including but not limited to
-damages for loss of goodwill, work stoppage, computer failure or malfunction, or
-any and all other commercial damages or losses), even if such Contributor has
-been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability.
-
-While redistributing the Work or Derivative Works thereof, You may choose to
-offer, and charge a fee for, acceptance of support, warranty, indemnity, or
-other liability obligations and/or rights consistent with this License. However,
-in accepting such obligations, You may act only on Your own behalf and on Your
-sole responsibility, not on behalf of any other Contributor, and only if You
-agree to indemnify, defend, and hold each Contributor harmless for any liability
-incurred by, or claims asserted against, such Contributor by reason of your
-accepting any such warranty or additional liability.
-
----
-
-http_parser.c is based on src/http/ngx_http_parse.c from NGINX copyright
-Igor Sysoev.
-
-Additional changes are licensed under the same terms as NGINX and
-copyright Joyent, Inc. and other Node contributors. All rights reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-IN THE SOFTWARE.
--- a/README.md	Fri Jan 04 13:27:32 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-# HTTP and HTTPS library for mbed OS 5
-
-This library is used to make HTTP and HTTPS calls from Mbed OS 5 applications.
-
-## HTTP Request API
-
-```cpp
-NetworkInterface* network = /* obtain a NetworkInterface object */
-
-const char body[] = "{\"hello\":\"world\"}";
-
-HttpRequest* request = new HttpRequest(network, HTTP_POST, "http://httpbin.org/post");
-request->set_header("Content-Type", "application/json");
-HttpResponse* response = request->send(body, strlen(body));
-// if response is NULL, check response->get_error()
-
-printf("status is %d - %s\n", response->get_status_code(), response->get_status_message());
-printf("body is:\n%s\n", response->get_body_as_string().c_str());
-
-delete request; // also clears out the response
-```
-
-## HTTPS Request API
-
-```cpp
-// pass in the root certificates that you trust, there is no central CA registry in Mbed OS
-const char SSL_CA_PEM[] = "-----BEGIN CERTIFICATE-----\n"
-    /* rest of the CA root certificates */;
-
-NetworkInterface* network = /* obtain a NetworkInterface object */
-
-const char body[] = "{\"hello\":\"world\"}";
-
-HttpsRequest* request = new HttpsRequest(network, SSL_CA_PEM, HTTP_GET "https://httpbin.org/status/418");
-HttpResponse* response = request->send();
-// if response is NULL, check response->get_error()
-
-printf("status is %d - %s\n", response->get_status_code(), response->get_status_message());
-printf("body is:\n%s\n", response->get_body().c_str());
-
-delete request;
-```
-
-**Note:** You can get the root CA for a domain easily from Firefox. Click on the green padlock, click *More information > Security > View certificate > Details*. Select the top entry in the 'Certificate Hierarchy' and click *Export...*. This gives you a PEM file. Add the content of the PEM file to your root CA list ([here's an image](img/root-ca-selection.png)).
-
-### Mbed TLS Entropy configuration
-
-If your target does not have a built-in TRNG, or other entropy sources, add the following macros to your `mbed_app.json` file to disable entropy:
-
-```json
-{
-    "macros": [
-        "MBEDTLS_TEST_NULL_ENTROPY",
-        "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES"
-    ]
-}
-```
-
-Note that this is **not** secure, and you should not deploy this device into production with this configuration.
-
-## Memory usage
-
-Small requests where the body of the response is cached by the library (like the one found in main-http.cpp), require ~4K of RAM. When the request is finished they require ~1.5K of RAM, depending on the size of the response. This applies both to HTTP and HTTPS. If you need to handle requests that return a large response body, see 'Dealing with large body'.
-
-HTTPS requires additional memory: on FRDM-K64F about 50K of heap space (at its peak). This means that you cannot use HTTPS on devices with less than 128K of memory, as you also need to reserve memory for the stack and network interface.
-
-### Dealing with large response body
-
-By default the library will store the full request body on the heap. This works well for small responses, but you'll run out of memory when receiving a large response body. To mitigate this you can pass in a callback as the last argument to the request constructor. This callback will be called whenever a chunk of the body is received. You can set the request chunk size in the `HTTP_RECEIVE_BUFFER_SIZE` macro (see `mbed_lib.json` for the definition) although it also depends on the buffer size of the underlying network connection.
-
-```cpp
-void body_callback(const char* data, uint32_t data_len) {
-    // do something with the data
-}
-
-HttpRequest* req = new HttpRequest(network, HTTP_GET, "http://pathtolargefile.com", &body_callback);
-req->send(NULL, 0);
-```
-
-### Dealing with a large request body
-
-If you cannot load the full request into memory, you can pass a callback into the `send` function. Through this callback you can feed in chunks of the request body. This is very useful if you want to send files from a file system.
-
-```cpp
-const void * get_chunk(uint32_t* out_size) {
-    // set the value of out_size (via *out_size = 10) to the size of the buffer
-    // return the buffer
-
-    // if you don't have any more data, set *out_size to 0
-}
-
-HttpRequest* req = new HttpRequest(network, HTTP_POST, "http://my_api.com/upload");
-req->send(callback(&get_chunk));
-```
-
-## Socket re-use
-
-By default the library opens a new socket per request. This is wasteful, especially when dealing with TLS requests. You can re-use sockets like this:
-
-### HTTP
-
-```cpp
-TCPSocket* socket = new TCPSocket();
-
-nsapi_error_t open_result = socket->open(network);
-// check open_result
-
-nsapi_error_t connect_result = socket->connect("httpbin.org", 80);
-// check connect_result
-
-// Pass in `socket`, instead of `network` as first argument
-HttpRequest* req = new HttpRequest(socket, HTTP_GET, "http://httpbin.org/status/418");
-```
-
-### HTTPS
-
-```cpp
-TLSSocket* socket = new TLSSocket();
-
-nsapi_error_t r;
-// make sure to check the return values for the calls below (should return NSAPI_ERROR_OK)
-r = socket->open(network);
-r = socket->set_root_ca_cert(SSL_CA_PEM);
-r = socket->connect("httpbin.org", 443);
-
-// Pass in `socket`, instead of `network` as first argument, and omit the `SSL_CA_PEM` argument
-HttpsRequest* get_req = new HttpsRequest(socket, HTTP_GET, "https://httpbin.org/status/418");
-```
-
-## Request logging
-
-To make debugging easier you can log the raw request body that goes over the line. This also works with chunked encoding.
-
-```cpp
-uint8_t *request_buffer = (uint8_t*)calloc(2048, 1);
-req->set_request_log_buffer(request_buffer, 2048);
-
-// after the request is done:
-printf("\n----- Request buffer -----\n");
-for (size_t ix = 0; ix < req->get_request_log_buffer_length(); ix++) {
-    printf("%02x ", request_buffer[ix]);
-}
-printf("\n");
-```
-
-## Integration tests
-
-Integration tests are located in the `TESTS` folder and are ran through [Greentea](https://github.com/ARMmbed/greentea). Instructions on how to run the tests are in [http-example](https://os.mbed.com/teams/sandbox/code/http-example/).
-
-## Mbed OS 5.10 or lower
-
-If you want to use this library on Mbed OS 5.10 or lower, you need to add the [TLSSocket](https://github.com/ARMmbed/TLSSocket) library to your project. This library is included in Mbed OS 5.11 and up.
-
-## Tested on
-
-* K64F with Ethernet.
-* NUCLEO_F411RE with ESP8266.
-* ODIN-W2 with WiFi.
-* K64F with Atmel 6LoWPAN shield.
-* DISCO-L475VG-IOT01A with WiFi.
-* [Mbed Simulator](https://github.com/janjongboom/mbed-simulator).
-
-But this should work with any Mbed OS 5 device that implements the `NetworkInterface` API.
--- a/TESTS/COMMON/test_setup.h	Fri Jan 04 13:27:32 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-#ifndef _MBED_HTTP_TEST_SETUP_H_
-#define _MBED_HTTP_TEST_SETUP_H_
-
-#include "mbed.h"
-#include "NetworkInterface.h"
-
-/**
- * Connect to the network using the default networking interface,
- * you can also swap this out with a driver for a different networking interface
- * if you use WiFi: see mbed_app.json for the credentials
- */
-NetworkInterface *connect_to_default_network_interface() {
-    NetworkInterface* network = NetworkInterface::get_default_instance();
-
-    if (!network) {
-        return NULL;
-    }
-
-    nsapi_error_t connect_status = network->connect();
-
-    if (connect_status != NSAPI_ERROR_OK) {
-        return NULL;
-    }
-
-    return network;
-}
-
-
-/* List of trusted root CA certificates
- *
- * - Amazon, the CA for os.mbed.com
- * - Let's Encrypt, the CA for httpbin.org
- * - Comodo, the CA for reqres.in
- *
- * To add more root certificates, just concatenate them.
- */
-const char SSL_CA_PEM[] =  "-----BEGIN CERTIFICATE-----\n"
-    "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n"
-    "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n"
-    "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n"
-    "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n"
-    "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n"
-    "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n"
-    "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n"
-    "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n"
-    "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n"
-    "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n"
-    "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n"
-    "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n"
-    "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n"
-    "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n"
-    "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n"
-    "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n"
-    "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n"
-    "rqXRfboQnoZsG4q5WTP468SQvvG5\n"
-    "-----END CERTIFICATE-----\n"
-    "-----BEGIN CERTIFICATE-----\n"
-    "MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/\n"
-    "MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n"
-    "DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0Nlow\n"
-    "SjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMT\n"
-    "GkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOC\n"
-    "AQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EF\n"
-    "q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8\n"
-    "SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0\n"
-    "Z8h/pZq4UmEU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"GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=\n"
-    "-----END CERTIFICATE-----\n";
-
-#endif // MBED_HTTP_TEST_SETUP_H_
--- a/TESTS/tests/integration/main.cpp	Fri Jan 04 13:27:32 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,266 +0,0 @@
-/*
- * PackageLicenseDeclared: Apache-2.0
- * Copyright (c) 2018 ARM Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mbed.h"
-#include "http_request.h"
-#include "https_request.h"
-#include "test_setup.h"
-#include "utest/utest.h"
-#include "unity/unity.h"
-#include "greentea-client/test_env.h"
-
-using namespace utest::v1;
-
-static NetworkInterface *network;
-
-static void setup_verify_network() {
-    if (!network) network = connect_to_default_network_interface();
-    TEST_ASSERT_NOT_NULL(network);
-}
-
-// verifies that the header is present and has a certain value
-static void assert_header(HttpResponse *res, const char *header, const char *value) {
-    bool headerPresent = false;
-    for (size_t ix = 0; ix < res->get_headers_length(); ix++) {
-        if (res->get_headers_fields()[ix]->compare(header)) {
-            headerPresent = true;
-
-            TEST_ASSERT(res->get_headers_values()[ix]->compare(value));
-        }
-    }
-    TEST_ASSERT_EQUAL(true, headerPresent);
-}
-
-static control_t http_get(const size_t call_count) {
-    setup_verify_network();
-
-    HttpRequest *req = new HttpRequest(network, HTTP_GET, "http://httpbin.org/status/418");
-
-    HttpResponse* res = req->send();
-    TEST_ASSERT(res);
-    TEST_ASSERT_EQUAL(418, res->get_status_code());
-
-    delete req;
-
-    return CaseNext;
-}
-
-static control_t http_post(const size_t call_count) {
-    setup_verify_network();
-
-    HttpRequest* req = new HttpRequest(network, HTTP_POST, "http://httpbin.org/post");
-    req->set_header("Content-Type", "application/json");
-
-    const char body[] = "{\"mykey\":\"mbedvalue\"}";
-
-    HttpResponse* res = req->send(body, strlen(body));
-    TEST_ASSERT(res);
-    TEST_ASSERT_EQUAL(200, res->get_status_code());
-
-    // verify that the Content-Type header is present, and set to application/json
-    assert_header(res, "Content-Type", "application/json");
-
-    // verify that both the key and value are present in the response
-    TEST_ASSERT(res->get_body_length() > 0);
-    TEST_ASSERT_NOT_EQUAL(res->get_body_as_string().find("mykey"), string::npos);
-    TEST_ASSERT_NOT_EQUAL(res->get_body_as_string().find("mbedvalue"), string::npos);
-
-    delete req;
-
-    return CaseNext;
-}
-
-static control_t http_socket_reuse(const size_t call_count) {
-    setup_verify_network();
-
-    TCPSocket socket;
-    nsapi_error_t open_result = socket.open(network);
-    TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, open_result);
-
-    nsapi_error_t connect_result = socket.connect("httpbin.org", 80);
-    TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, connect_result);
-
-    {
-        HttpRequest *req = new HttpRequest(&socket, HTTP_GET, "http://httpbin.org/status/404");
-
-        HttpResponse* res = req->send();
-        TEST_ASSERT(res);
-        TEST_ASSERT_EQUAL(404, res->get_status_code());
-
-        delete req;
-    }
-
-    {
-        HttpRequest *req = new HttpRequest(&socket, HTTP_GET, "http://httpbin.org/status/403");
-
-        HttpResponse* res = req->send();
-        TEST_ASSERT(res);
-        TEST_ASSERT_EQUAL(403, res->get_status_code());
-
-        delete req;
-    }
-
-    return CaseNext;
-}
-
-static control_t https_get(const size_t call_count) {
-    setup_verify_network();
-
-    HttpsRequest *req = new HttpsRequest(network, SSL_CA_PEM, HTTP_GET, "https://os.mbed.com/media/uploads/mbed_official/hello.txt");
-
-    HttpResponse* res = req->send();
-    TEST_ASSERT(res);
-    TEST_ASSERT_EQUAL(200, res->get_status_code());
-    TEST_ASSERT(res->get_body_length() > 0);
-    TEST_ASSERT_NOT_EQUAL(res->get_body_as_string().find("Hello world!"), string::npos);
-
-    delete req;
-
-    return CaseNext;
-}
-
-static control_t https_post(const size_t call_count) {
-    setup_verify_network();
-
-    HttpsRequest* req = new HttpsRequest(network, SSL_CA_PEM, HTTP_POST, "https://httpbin.org/post");
-    req->set_header("Content-Type", "application/json");
-
-    const char body[] = "{\"myhttpskey\":\"janjanjan\"}";
-
-    HttpResponse* res = req->send(body, strlen(body));
-    TEST_ASSERT(res);
-    TEST_ASSERT_EQUAL(200, res->get_status_code());
-
-    // verify that the Content-Type header is present, and set to application/json
-    assert_header(res, "Content-Type", "application/json");
-
-    // verify that both the key and value are present in the response
-    TEST_ASSERT(res->get_body_length() > 0);
-    TEST_ASSERT_NOT_EQUAL(res->get_body_as_string().find("myhttpskey"), string::npos);
-    TEST_ASSERT_NOT_EQUAL(res->get_body_as_string().find("janjanjan"), string::npos);
-
-    delete req;
-
-    return CaseNext;
-}
-
-static control_t https_socket_reuse(const size_t call_count) {
-    setup_verify_network();
-
-    TLSSocket socket;
-    nsapi_error_t open_result = socket.open(network);
-    TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, open_result);
-
-    nsapi_error_t ca_result = socket.set_root_ca_cert(SSL_CA_PEM);
-    TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, ca_result);
-
-    nsapi_error_t connect_result = socket.connect("httpbin.org", 443);
-    TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, connect_result);
-
-    {
-        HttpsRequest *req = new HttpsRequest(&socket, HTTP_GET, "http://httpbin.org/status/404");
-
-        HttpResponse* res = req->send();
-        TEST_ASSERT(res);
-        TEST_ASSERT_EQUAL(404, res->get_status_code());
-
-        delete req;
-    }
-
-    {
-        HttpsRequest *req = new HttpsRequest(&socket, HTTP_GET, "http://httpbin.org/status/403");
-
-        HttpResponse* res = req->send();
-        TEST_ASSERT(res);
-        TEST_ASSERT_EQUAL(403, res->get_status_code());
-
-        delete req;
-    }
-
-    return CaseNext;
-}
-
-// Spread the message out over 3 different chunks
-const char * chunks[] = {
-    "{\"message\":",
-    "\"this is an example",
-    " of chunked encoding\"}"
-};
-
-int chunk_ix = 0;
-
-// Callback function, grab the next chunk and return it
-const void * get_chunk(uint32_t* out_size) {
-    // If you don't have any data left, set out_size to 0 and return a null pointer
-    if (chunk_ix == (sizeof(chunks) / sizeof(chunks[0]))) {
-        *out_size = 0;
-        return NULL;
-    }
-    const char *chunk = chunks[chunk_ix];
-    *out_size = strlen(chunk);
-    chunk_ix++;
-
-    return chunk;
-}
-
-static control_t chunked_request(const size_t call_count) {
-    setup_verify_network();
-
-    HttpsRequest *req = new HttpsRequest(network, SSL_CA_PEM, HTTP_POST, "https://reqres.in/api/users");
-    req->set_header("Content-Type", "application/json");
-
-    HttpResponse* res = req->send(&get_chunk);
-    TEST_ASSERT(res);
-    TEST_ASSERT_EQUAL(201, res->get_status_code());
-    TEST_ASSERT(res->get_body_length() > 0);
-    TEST_ASSERT_NOT_EQUAL(res->get_body_as_string().find("message"), string::npos);
-    TEST_ASSERT_NOT_EQUAL(res->get_body_as_string().find("this is an example of chunked encoding"), string::npos);
-    TEST_ASSERT_NOT_EQUAL(res->get_body_as_string().find("createdAt"), string::npos);
-
-    delete req;
-
-    return CaseNext;
-}
-
-utest::v1::status_t greentea_setup(const size_t number_of_cases) {
-    GREENTEA_SETUP(1*60, "default_auto");
-    return greentea_test_setup_handler(number_of_cases);
-}
-
-Case cases[] = {
-    Case("http get", http_get),
-    Case("http post", http_post),
-    Case("http socket reuse", http_socket_reuse),
-    Case("https get", https_get),
-    Case("https post", https_post),
-    Case("https socket reuse", https_socket_reuse),
-    Case("chunked request", chunked_request)
-};
-
-Specification specification(greentea_setup, cases);
-
-void blink_led() {
-    static DigitalOut led(LED1);
-    led = !led;
-}
-
-int main() {
-    Ticker t;
-    t.attach(blink_led, 0.5);
-
-    return !Harness::run(specification);
-}
Binary file img/root-ca-selection.png has changed
--- a/mbed_lib.json	Fri Jan 04 13:27:32 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-{
-    "name": "mbed-http",
-    "macros": [
-        "MBEDTLS_SHA1_C"
-    ],
-    "config": {
-        "http-buffer-size": {
-            "help": "Size of the HTTP receive buffer in bytes",
-            "value": 8192,
-            "macro_name": "HTTP_RECEIVE_BUFFER_SIZE"
-        }
-    }
-}