Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed wolfSSL
Fork of SimpleHTTPSClient by
Diff: main.cpp
- Revision:
- 5:12ff922de096
- Parent:
- 4:68c5a3f49a48
- Child:
- 6:81003a418b9c
diff -r 68c5a3f49a48 -r 12ff922de096 main.cpp --- a/main.cpp Sat Feb 07 19:14:32 2015 +0000 +++ b/main.cpp Tue Jul 21 23:11:13 2015 +0000 @@ -1,24 +1,16 @@ #include "mbed.h" #include "EthernetInterface.h" #include "HTTPClient.h" +#include "getline.h" EthernetInterface eth; HTTPClient http; char recvBuff[1024*20]; -void getline(char *line, int size) { - for(int i=0; i<size; i++) { - if((line[i] = getchar()) == '\r') { - line[i] = '\0' ; - putchar('\n') ; - break ; - } else putchar(line[i]) ; - } -} - void net_main(void const *av) { int ret ; + char url[100] ; eth.init(); //Use DHCP printf("HTTP Client, Starting,...\n") ; @@ -26,36 +18,26 @@ if(eth.connect() == 0)break ; printf("Retry\n") ; } - - /*** HTTP ***/ - printf("\nFetching HTTP\n"); - ret = http.get("http://SERVER_IP/574d76fcb/keys.txt", recvBuff, sizeof(recvBuff)); - if (!ret) { - printf("Result: %s\n", recvBuff); - } else { - printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); - } - - /*** HTTPS (SSL) ***/ - printf("\nFetching HTTPS\n"); - ret = http.get("https://SERVER_IP/574d76fcb/keys.txt", recvBuff, sizeof(recvBuff)); - if (!ret) { - printf("Result: %s\n", recvBuff); - } else { - printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); - } - - eth.disconnect(); + http.dumpReqHeader(true) ; + http.dumpResHeader(true) ; while(1) { + getline("URL: ", url, sizeof(url)) ; + if(strlen(url) == 0)return ; + /*** HTTP ***/ + printf("\nFetching HTTP\n"); + ret = http.get(url, recvBuff, sizeof(recvBuff)); + if (!ret) { + printf("Result: %s\n", recvBuff); + } else { + printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); + } } } main() { - -#define STACK_SIZE 20000 +#define STACK_SIZE 24000 Thread t(net_main, NULL, osPriorityNormal, STACK_SIZE); - while (true) { Thread::wait(1000); }