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 SDFileSystem mbed-rtos mbed wolfSSL
Fork of SimpleDropbox by
Diff: dropbox.cpp
- Revision:
- 0:b20eee676480
- Child:
- 3:0bf592148055
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dropbox.cpp Mon Dec 08 12:03:12 2014 +0000
@@ -0,0 +1,54 @@
+/* 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) ;
+
+ ret = http.get(url, buff, size) ;
+ if (ret != HTTP_REDIRECT) {
+ printf("++ Err = %d - HTTP ret = %d ++\n",
+ ret, http.getHTTPResponseCode());
+ return ret ;
+ }
+
+ 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 ;
+}
