mbed-os
Fork of mbed-os by
features/unsupported/net/https/HTTPHeader.cpp@1:3deb71413561, 2017-07-20 (annotated)
- Committer:
- xuaner
- Date:
- Thu Jul 20 14:26:57 2017 +0000
- Revision:
- 1:3deb71413561
- Parent:
- 0:f269e3021894
mbed_os
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | #include "HTTPHeader.h" |
elessair | 0:f269e3021894 | 2 | #include <stdlib.h> |
elessair | 0:f269e3021894 | 3 | using std::map; |
elessair | 0:f269e3021894 | 4 | using std::string; |
elessair | 0:f269e3021894 | 5 | |
elessair | 0:f269e3021894 | 6 | HTTPHeader::HTTPHeader(): |
elessair | 0:f269e3021894 | 7 | _status(HTTP_ERROR), |
elessair | 0:f269e3021894 | 8 | _fields() |
elessair | 0:f269e3021894 | 9 | { |
elessair | 0:f269e3021894 | 10 | } |
elessair | 0:f269e3021894 | 11 | |
elessair | 0:f269e3021894 | 12 | std::string HTTPHeader::getField(const std::string& name) |
elessair | 0:f269e3021894 | 13 | { |
elessair | 0:f269e3021894 | 14 | map<string,string>::iterator itor = _fields.find(name); |
elessair | 0:f269e3021894 | 15 | if(itor == _fields.end()) |
elessair | 0:f269e3021894 | 16 | return string(); |
elessair | 0:f269e3021894 | 17 | return itor->second; |
elessair | 0:f269e3021894 | 18 | } |
elessair | 0:f269e3021894 | 19 | |
elessair | 0:f269e3021894 | 20 | int HTTPHeader::getBodyLength() |
elessair | 0:f269e3021894 | 21 | { |
elessair | 0:f269e3021894 | 22 | return atoi(getField("Content-Length").c_str()); |
elessair | 0:f269e3021894 | 23 | } |
elessair | 0:f269e3021894 | 24 |