dropbox access

Dependencies:   EthernetInterface HTTPClient mbed-rtos mbed

Fork of SimpleDropbox by wolf SSL

Committer:
thursday1024
Date:
Wed Jul 22 08:30:52 2015 +0000
Revision:
2:3b43fb225342
Parent:
0:b20eee676480
dropbox access

Who changed what in which revision?

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