Fork HTTPClient and Modfiy code for mbed 6.0
Dependents: mbed-demo-http-get-json
data/HTTPJson.cpp@51:a9ed5a6eee90, 2020-11-08 (annotated)
- Committer:
- quxiaorui
- Date:
- Sun Nov 08 10:33:36 2020 +0000
- Revision:
- 51:a9ed5a6eee90
- Parent:
- 37:74c1c4527f70
remove unnecessary annotation.
Who changed what in which revision?
User | Revision | Line number | New 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 | } |