]>
git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/tests/net/cellular/http/common/httptest.cpp
2 #include "CellularModem.h"
3 #include "HTTPClient.h"
6 int httptest(CellularModem
& modem
, const char* apn
, const char* username
, const char* password
)
8 printf("Connecting...\n");
15 int ret
= modem
.connect(apn
, username
, password
);
18 printf("Could not connect\n");
23 printf("Trying to fetch page...\n");
24 ret
= http
.get("http://mbed.org/media/uploads/donatien/hello.txt", str
, 128);
27 printf("Page fetched successfully - read %d characters\n", strlen(str
));
28 printf("Result: %s\n", str
);
32 printf("Error - ret = %d - HTTP return code = %d\n", ret
, http
.getHTTPResponseCode());
39 HTTPText
text(str
, 512);
40 map
.put("Hello", "World");
41 map
.put("test", "1234");
42 printf("Trying to post data...\n");
43 ret
= http
.post("http://httpbin.org/post", map
, &text
);
46 printf("Executed POST successfully - read %d characters\n", strlen(str
));
47 printf("Result: %s\n", str
);
51 printf("Error - ret = %d - HTTP return code = %d\n", ret
, http
.getHTTPResponseCode());