A HTTP/HTTPS Client for the mbed networking/CyaSSL ssl library

Dependents:   Anpi Example--Dropbox Example-Xively dropbox_access ... more

Fork of HTTPClient by Donatien Garnier

HTTP and HTTPS Client Class with wolfSSL, embedded SSL library.

/media/uploads/wolfSSL/wolfssl_logo.png

The class was forked from http://mbed.org/users/donatien/code/HTTPClient/

It, now, accepts url both with "http://" and "https://".

Allocate caller thread with 16kbytes or larger stack for "https" requests.

Rest of the API stays compatible with HTTPClient.

For more about the library, see http://www.wolfssl.com. http://wolfssl.com/yaSSL/Docs.html.

Extended methods:

Committer:
wolfSSL
Date:
Thu Apr 28 00:55:27 2016 +0000
Revision:
34:76aa4f4021c1
Parent:
13:be61104f4e91
Sync with wolfSSL 3.9.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien0:2ccb9960a044 1/* IHTTPData.h */
donatien10:e1351de84c16 2/* Copyright (C) 2012 mbed.org, MIT License
donatien10:e1351de84c16 3 *
donatien10:e1351de84c16 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
donatien10:e1351de84c16 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
donatien10:e1351de84c16 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
donatien10:e1351de84c16 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
donatien10:e1351de84c16 8 * furnished to do so, subject to the following conditions:
donatien10:e1351de84c16 9 *
donatien10:e1351de84c16 10 * The above copyright notice and this permission notice shall be included in all copies or
donatien10:e1351de84c16 11 * substantial portions of the Software.
donatien10:e1351de84c16 12 *
donatien10:e1351de84c16 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
donatien10:e1351de84c16 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
donatien10:e1351de84c16 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
donatien10:e1351de84c16 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien10:e1351de84c16 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
donatien10:e1351de84c16 18 */
donatien0:2ccb9960a044 19
donatien0:2ccb9960a044 20#ifndef IHTTPDATA_H
donatien0:2ccb9960a044 21#define IHTTPDATA_H
donatien0:2ccb9960a044 22
donatien13:be61104f4e91 23#include <cstring>
donatien13:be61104f4e91 24
donatien13:be61104f4e91 25using std::size_t;
donatien13:be61104f4e91 26
donatien0:2ccb9960a044 27///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...)
donatien0:2ccb9960a044 28class IHTTPDataOut
donatien0:2ccb9960a044 29{
donatien0:2ccb9960a044 30protected:
donatien0:2ccb9960a044 31 friend class HTTPClient;
donatien16:1f743885e7de 32
donatien16:1f743885e7de 33 /** Reset stream to its beginning
donatien16:1f743885e7de 34 * Called by the HTTPClient on each new request
donatien16:1f743885e7de 35 */
donatien16:1f743885e7de 36 virtual void readReset() = 0;
donatien0:2ccb9960a044 37
donatien0:2ccb9960a044 38 /** Read a piece of data to be transmitted
donatien0:2ccb9960a044 39 * @param buf Pointer to the buffer on which to copy the data
donatien0:2ccb9960a044 40 * @param len Length of the buffer
donatien0:2ccb9960a044 41 * @param pReadLen Pointer to the variable on which the actual copied data length will be stored
donatien0:2ccb9960a044 42 */
donatien0:2ccb9960a044 43 virtual int read(char* buf, size_t len, size_t* pReadLen) = 0;
donatien0:2ccb9960a044 44
donatien0:2ccb9960a044 45 /** Get MIME type
donatien0:2ccb9960a044 46 * @param type Internet media type from Content-Type header
donatien0:2ccb9960a044 47 */
donatien0:2ccb9960a044 48 virtual int getDataType(char* type, size_t maxTypeLen) = 0; //Internet media type for Content-Type header
donatien0:2ccb9960a044 49
donatien0:2ccb9960a044 50 /** Determine whether the HTTP client should chunk the data
donatien0:2ccb9960a044 51 * Used for Transfer-Encoding header
donatien0:2ccb9960a044 52 */
donatien0:2ccb9960a044 53 virtual bool getIsChunked() = 0;
donatien0:2ccb9960a044 54
donatien0:2ccb9960a044 55 /** If the data is not chunked, get its size
donatien0:2ccb9960a044 56 * Used for Content-Length header
donatien0:2ccb9960a044 57 */
donatien0:2ccb9960a044 58 virtual size_t getDataLen() = 0;
donatien0:2ccb9960a044 59
donatien0:2ccb9960a044 60};
donatien0:2ccb9960a044 61
donatien0:2ccb9960a044 62///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...)
donatien0:2ccb9960a044 63class IHTTPDataIn
donatien0:2ccb9960a044 64{
donatien0:2ccb9960a044 65protected:
donatien0:2ccb9960a044 66 friend class HTTPClient;
donatien0:2ccb9960a044 67
donatien16:1f743885e7de 68 /** Reset stream to its beginning
donatien16:1f743885e7de 69 * Called by the HTTPClient on each new request
donatien16:1f743885e7de 70 */
donatien16:1f743885e7de 71 virtual void writeReset() = 0;
donatien16:1f743885e7de 72
donatien0:2ccb9960a044 73 /** Write a piece of data transmitted by the server
donatien0:2ccb9960a044 74 * @param buf Pointer to the buffer from which to copy the data
donatien0:2ccb9960a044 75 * @param len Length of the buffer
donatien0:2ccb9960a044 76 */
donatien0:2ccb9960a044 77 virtual int write(const char* buf, size_t len) = 0;
donatien0:2ccb9960a044 78
donatien0:2ccb9960a044 79 /** Set MIME type
donatien0:2ccb9960a044 80 * @param type Internet media type from Content-Type header
donatien0:2ccb9960a044 81 */
donatien0:2ccb9960a044 82 virtual void setDataType(const char* type) = 0;
donatien0:2ccb9960a044 83
donatien0:2ccb9960a044 84 /** Determine whether the data is chunked
donatien0:2ccb9960a044 85 * Recovered from Transfer-Encoding header
donatien0:2ccb9960a044 86 */
donatien0:2ccb9960a044 87 virtual void setIsChunked(bool chunked) = 0;
donatien0:2ccb9960a044 88
donatien0:2ccb9960a044 89 /** If the data is not chunked, set its size
donatien0:2ccb9960a044 90 * From Content-Length header
donatien0:2ccb9960a044 91 */
donatien0:2ccb9960a044 92 virtual void setDataLen(size_t len) = 0;
donatien0:2ccb9960a044 93
donatien0:2ccb9960a044 94};
donatien0:2ccb9960a044 95
donatien0:2ccb9960a044 96#endif