Fixed custom headers and Basic authorization, added support for redirection, functional file download interface can be used for SW updates and more.

Dependents:   Sample_HTTPClient Sample_HTTPClient LWM2M_NanoService_Ethernet LWM2M_NanoService_Ethernet ... more

Fork of HTTPClient by Vincent Wochnik

More recent changes - added iCal processing.

Derivative of a derivative, however this one works when it comes to supplying Basic authorization to access a protected resource. Some additional changes to the debug interface to clean it up for consistency with many other components I have.

Committer:
WiredHome
Date:
Wed Apr 03 22:00:31 2019 +0000
Revision:
48:61c26e0111c9
Parent:
37:74c1c4527f70
Minor change to a memory allocation for header parsing.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 37:74c1c4527f70 1 /* HTTPJson.cpp */
WiredHome 37:74c1c4527f70 2 /* Copyright (C) 2012 mbed.org, MIT License
WiredHome 37:74c1c4527f70 3 *
WiredHome 37:74c1c4527f70 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
WiredHome 37:74c1c4527f70 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
WiredHome 37:74c1c4527f70 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
WiredHome 37:74c1c4527f70 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
WiredHome 37:74c1c4527f70 8 * furnished to do so, subject to the following conditions:
WiredHome 37:74c1c4527f70 9 *
WiredHome 37:74c1c4527f70 10 * The above copyright notice and this permission notice shall be included in all copies or
WiredHome 37:74c1c4527f70 11 * substantial portions of the Software.
WiredHome 37:74c1c4527f70 12 *
WiredHome 37:74c1c4527f70 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
WiredHome 37:74c1c4527f70 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
WiredHome 37:74c1c4527f70 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
WiredHome 37:74c1c4527f70 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
WiredHome 37:74c1c4527f70 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WiredHome 37:74c1c4527f70 18 */
WiredHome 37:74c1c4527f70 19
WiredHome 37:74c1c4527f70 20 #include "HTTPJson.h"
WiredHome 37:74c1c4527f70 21
WiredHome 37:74c1c4527f70 22 #define OK 0
WiredHome 37:74c1c4527f70 23
WiredHome 37:74c1c4527f70 24 using std::strncpy;
WiredHome 37:74c1c4527f70 25
WiredHome 37:74c1c4527f70 26 HTTPJson::HTTPJson(char* json_str) : HTTPText(json_str)
WiredHome 37:74c1c4527f70 27 {
WiredHome 37:74c1c4527f70 28
WiredHome 37:74c1c4527f70 29 }
WiredHome 37:74c1c4527f70 30
WiredHome 37:74c1c4527f70 31 HTTPJson::HTTPJson(char* json_str, size_t size) : HTTPText(json_str,size)
WiredHome 37:74c1c4527f70 32 {
WiredHome 37:74c1c4527f70 33
WiredHome 37:74c1c4527f70 34 }
WiredHome 37:74c1c4527f70 35
WiredHome 37:74c1c4527f70 36 /*virtual*/ int HTTPJson::getDataType(char* type, size_t maxTypeLen) //Internet media type for Content-Type header
WiredHome 37:74c1c4527f70 37 {
WiredHome 37:74c1c4527f70 38 strncpy(type, "application/json", maxTypeLen-1);
WiredHome 37:74c1c4527f70 39 type[maxTypeLen-1] = '\0';
WiredHome 37:74c1c4527f70 40 return OK;
WiredHome 37:74c1c4527f70 41 }