dropbox access

Dependencies:   EthernetInterface HTTPClient mbed-rtos mbed

Fork of SimpleDropbox by wolf SSL

Committer:
wolfSSL
Date:
Mon Dec 08 12:03:12 2014 +0000
Revision:
0:b20eee676480
Child:
2:3b43fb225342
Initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 0:b20eee676480 1 /* dropbox.c
wolfSSL 0:b20eee676480 2 *
wolfSSL 0:b20eee676480 3 * Copyright (C) 2006-2014 wolfSSL Inc.
wolfSSL 0:b20eee676480 4 *
wolfSSL 0:b20eee676480 5 * This file is part of CyaSSL.
wolfSSL 0:b20eee676480 6 *
wolfSSL 0:b20eee676480 7 * CyaSSL is free software; you can redistribute it and/or modify
wolfSSL 0:b20eee676480 8 * it under the terms of the GNU General Public License as published by
wolfSSL 0:b20eee676480 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 0:b20eee676480 10 * (at your option) any later version.
wolfSSL 0:b20eee676480 11 *
wolfSSL 0:b20eee676480 12 * CyaSSL is distributed in the hope that it will be useful,
wolfSSL 0:b20eee676480 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 0:b20eee676480 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 0:b20eee676480 15 * GNU General Public License for more details.
wolfSSL 0:b20eee676480 16 *
wolfSSL 0:b20eee676480 17 * You should have received a copy of the GNU General Public License
wolfSSL 0:b20eee676480 18 * along with this program; if not, write to the Free Software
wolfSSL 0:b20eee676480 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
wolfSSL 0:b20eee676480 20 */
wolfSSL 0:b20eee676480 21
wolfSSL 0:b20eee676480 22 #include "mbed.h"
wolfSSL 0:b20eee676480 23 #include "EthernetInterface.h"
wolfSSL 0:b20eee676480 24 #include "HTTPClient.h"
wolfSSL 0:b20eee676480 25
wolfSSL 0:b20eee676480 26 extern HTTPClient http;
wolfSSL 0:b20eee676480 27
wolfSSL 0:b20eee676480 28 HTTPResult dropbox_get(const char *url, char *buff, int size)
wolfSSL 0:b20eee676480 29 {
wolfSSL 0:b20eee676480 30 HTTPResult ret ;
wolfSSL 0:b20eee676480 31 #define LOCATION_SIZE 128
wolfSSL 0:b20eee676480 32 static char location[LOCATION_SIZE] ;
wolfSSL 0:b20eee676480 33 static const char HeaderLines[] =
wolfSSL 0:b20eee676480 34 "User-Agent: curl/7.33.0\r\n"
wolfSSL 0:b20eee676480 35 "Accept: */*\r\n" ;
wolfSSL 0:b20eee676480 36
wolfSSL 0:b20eee676480 37 http.setHeader(HeaderLines) ;
wolfSSL 0:b20eee676480 38 http.setLocationBuf(location, LOCATION_SIZE) ;
wolfSSL 0:b20eee676480 39
wolfSSL 0:b20eee676480 40 ret = http.get(url, buff, size) ;
wolfSSL 0:b20eee676480 41 if (ret != HTTP_REDIRECT) {
wolfSSL 0:b20eee676480 42 printf("++ Err = %d - HTTP ret = %d ++\n",
wolfSSL 0:b20eee676480 43 ret, http.getHTTPResponseCode());
wolfSSL 0:b20eee676480 44 return ret ;
wolfSSL 0:b20eee676480 45 }
wolfSSL 0:b20eee676480 46
wolfSSL 0:b20eee676480 47 ret = http.get(location, buff, size) ;
wolfSSL 0:b20eee676480 48 if (ret != HTTP_OK) {
wolfSSL 0:b20eee676480 49 printf("++ Err = %d - HTTP ret = %d ++\n",
wolfSSL 0:b20eee676480 50 ret, http.getHTTPResponseCode());
wolfSSL 0:b20eee676480 51 return ret ;
wolfSSL 0:b20eee676480 52 }
wolfSSL 0:b20eee676480 53 return HTTP_OK ;
wolfSSL 0:b20eee676480 54 }