Usage example, Dropbox with wolfSSL
Dependencies: EthernetInterface HTTPClient SDFileSystem mbed-rtos mbed wolfSSL
Fork of SimpleDropbox by
dropbox.cpp
- Committer:
- wolfSSL
- Date:
- 2015-07-21
- Revision:
- 3:0bf592148055
- Parent:
- 0:b20eee676480
File content as of revision 3:0bf592148055:
/* dropbox.c * * Copyright (C) 2006-2014 wolfSSL Inc. * * This file is part of CyaSSL. * * CyaSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CyaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include "mbed.h" #include "EthernetInterface.h" #include "HTTPClient.h" extern HTTPClient http; HTTPResult dropbox_get(const char *url, char *buff, int size) { HTTPResult ret ; #define LOCATION_SIZE 128 static char location[LOCATION_SIZE] ; static const char HeaderLines[] = "User-Agent: curl/7.33.0\r\n" "Accept: */*\r\n" ; http.setHeader(HeaderLines) ; http.setLocationBuf(location, LOCATION_SIZE) ; http.dumpReqHeader(true) ; http.dumpResHeader(true) ; ret = http.get(url, buff, size) ; if (ret != HTTP_REDIRECT) { printf("++ Err = %d - HTTP ret = %d ++\n", ret, http.getHTTPResponseCode()); return ret ; } printf("\nHTTP GET: %s\n\n", location) ; http.dumpReqHeader(false) ; http.dumpResHeader(false) ; ret = http.get(location, buff, size) ; if (ret != HTTP_OK) { printf("++ Err = %d - HTTP ret = %d ++\n", ret, http.getHTTPResponseCode()); return ret ; } return HTTP_OK ; }