bool BaseHTTPProtocol::SignalInputData(IOBuffer &buffer) { DEBUG_HTTP("-------------------"); DEBUG_HTTP("%s", STR(*this)); DEBUG_HTTP("_state: %s", (_state == HTTP_STATE_HEADERS) ? "HTTP_STATE_HEADERS" : (_state == HTTP_STATE_PAYLOAD) ? "HTTP_STATE_PAYLOAD" : "UNKNOWN"); //1. Get the first line and the headers if necessary if (_state == HTTP_STATE_HEADERS) { DEBUG_HTTP("Parse the headers"); if (!ParseHeaders(buffer)) { FATAL("Unable to read response headers: %s", STR(*this)); return false; } } DEBUG_HTTP("_continueAfterParseHeaders: %d", _continueAfterParseHeaders); if (!_continueAfterParseHeaders) return true; //2. Are we still in the "get headers state"? If so, wait for more data DEBUG_HTTP("new value of _state: %s", (_state == HTTP_STATE_HEADERS) ? "HTTP_STATE_HEADERS" : (_state == HTTP_STATE_PAYLOAD) ? "HTTP_STATE_PAYLOAD" : "UNKNOWN"); if (_state != HTTP_STATE_PAYLOAD) { return true; } DEBUG_HTTP("_chunkedContent: %d", _chunkedContent); //3. Turning point in processing if (_chunkedContent) { //4. We deal with chunked content DEBUG_HTTP("begin chunk content handling"); if (!HandleChunkedContent(buffer)) { FATAL("Unable to handle chunked content: %s", STR(*this)); return false; } } else { //5. We deal with length-specified type of content DEBUG_HTTP("begin fixed length content handling"); if (!HandleFixedLengthContent(buffer)) { FATAL("Unable to handle fixed length content: %s", STR(*this)); return false; } } //6. Are we in the get headers state? if so, we might have a new request //on the pipe. DEBUG_HTTP("brand new value of _state: %s", (_state == HTTP_STATE_HEADERS) ? "HTTP_STATE_HEADERS" : (_state == HTTP_STATE_PAYLOAD) ? "HTTP_STATE_PAYLOAD" : "UNKNOWN"); if (_state == HTTP_STATE_HEADERS) { DEBUG_HTTP("Call SignalInputData again"); //7. So, get to work again... return SignalInputData(buffer); } else { //8 We are done :) DEBUG_HTTP("Done"); return true; } }
bool BaseHTTPProtocol::SignalInputData(IOBuffer &buffer) { //1. Get the first line and the headers if necessary if (_state == HTTP_STATE_HEADERS) { if (!ParseHeaders(buffer)) { FATAL("Unable to read response headers"); return false; } } if (!_continueAfterParseHeaders) return true; //2. Are we still in the "get headers state"? If so, wait for more data if (_state != HTTP_STATE_PAYLOAD) { return true; } //3. Turning point in processing if (_chunkedContent) { //4. We deal with chunked content if (!HandleChunkedContent(buffer)) { FATAL("Unable to handle chunked content"); return false; } } else { //5. We deal with length-specified type of content if (!HandleFixedLengthContent(buffer)) { FATAL("Unable to handle fixed length content"); return false; } } //6. Are we in the get headers state? if so, we might have a new request //on the pipe. if (_state == HTTP_STATE_HEADERS) { //7. So, get to work again... return SignalInputData(buffer); } else { //8 We are done :) return true; } }