A client for the SmartREST protocol from Cumulocity.
Fork of MbedSmartRest by
Diff: HTTPResponseFilter.cpp
- Revision:
- 16:ee4f052c7570
- Parent:
- 15:0ce90c525e7a
--- a/HTTPResponseFilter.cpp Tue Apr 15 16:57:53 2014 +0000 +++ b/HTTPResponseFilter.cpp Wed Apr 16 07:44:19 2014 +0000 @@ -20,6 +20,9 @@ { if (_state != RESPF_STATE_READ_HEADERS) return 0; + if ((_length > 0) && (_length == _read)) + return 0; + _read++; return _source.read(); } @@ -27,6 +30,8 @@ { if (_state != RESPF_STATE_READ_HEADERS) return DS_STATUS_ERROR; + if ((_length > 0) && (_length == _read)) + return DS_STATUS_CLOSED; return _source.status(); } @@ -89,12 +94,12 @@ offset++; break; case 1: - if (offset == strlen(cContentLength) - state = 2; - else if (c == '\r') + if (c == '\r') state = 3; else if (cContentLength[offset] != c) state = 0; + else if (offset == strlen(cContentLength)-1) + state = 2; offset++; break; case 2: @@ -119,9 +124,9 @@ } } - if ((status != DS_STATUS_OK) || (state != 3)) + if ((status != DS_STATUS_OK) || (state != 5)) return false; - + _state = RESPF_STATE_READ_HEADERS; return true; }