Пример #1
0
    ChunkedReader::int_type ChunkedReader::underflow()
    {
      log_trace("ChunkedReader::underflow");

      while (_state != 0
        && gptr() == egptr()
        && _ib->sgetc() != traits_type::eof())
      {
        (this->*_state)();
      }

      if (_state == 0)
      {
        log_debug("end of chunked data reached");
        return traits_type::eof();
      }

      if (_ib->sgetc() == traits_type::eof())
      {
        log_debug("end of input stream");
        _state = 0;
        return traits_type::eof();
      }

      log_debug("not at eof - return " << charToPrint(*gptr()));
      return *gptr();
    }
Пример #2
0
void ChunkParser::onTrailerData(char ch)
{
    log_trace("onTrailerData, ch=" << charToPrint(ch));

    // the trailer is actually ignored
    if (ch == '\n')
        _state = &ChunkParser::onTrailer;
}
Пример #3
0
void ChunkParser::onDataEnd(char ch)
{
    log_trace("onDataEnd, ch=" << charToPrint(ch));

    if (ch == '\n')
    {
        log_debug("=> onBegin");
        _state = &ChunkParser::onBegin;
    }
    else
        throwInvalidCharacter(ch);
}
Пример #4
0
void ChunkParser::onTrailer(char ch)
{
    log_trace("onTrailer, ch=" << charToPrint(ch));

    // @todo Report trailer fields by adding them to the other header fields.
    //       HttpBuffer and ChunkParser need a reference to a MessageHeader.

    if (ch == '\n')
        _state = 0;
    else if (ch == '\r')
        ;
    else
        _state = &ChunkParser::onTrailerData;
}
Пример #5
0
void ChunkParser::onEndl(char ch)
{
    log_trace("onEndl, ch=" << charToPrint(ch));

    if (ch == '\n')
    {
      if (_chunkSize > 0)
          _state = &ChunkParser::onData;
      else
          _state = &ChunkParser::onTrailer;
    }
    else
        throwInvalidCharacter(ch);
}
Пример #6
0
    void ChunkedReader::onDataEnd()
    {
      char ch = _ib->sbumpc();

      log_trace("onDataEnd, ch=" << charToPrint(ch));

      if (ch == '\n')
      {
        log_debug("=> onBegin");
        _state = &ChunkedReader::onBegin;
      }
      else
        throwInvalidCharacter(ch);
    }
Пример #7
0
    void ChunkedReader::onEndl()
    {
      char ch = _ib->sbumpc();

      log_trace("onEndl, ch=" << charToPrint(ch));

      if (ch == '\n')
      {
        if (_chunkSize > 0)
          _state = &ChunkedReader::onData;
        else
          _state = &ChunkedReader::onTrailer;
      }
      else
        throwInvalidCharacter(ch);
    }
Пример #8
0
void ChunkParser::onBegin(char ch)
{
    log_trace("onBegin, ch=" << charToPrint(ch));

    if (ch >= '0' && ch <= '9')
    {
        _chunkSize = ch - '0';
        _state = &ChunkParser::onSize;
    }
    else if (ch >= 'a' && ch <= 'f')
    {
        _chunkSize = ch - 'a' + 10;
        _state = &ChunkParser::onSize;
    }
    else if (ch >= 'A' && ch <= 'F')
    {
        _chunkSize = ch - 'A' + 10;
        _state = &ChunkParser::onSize;
    }
    else
        throwInvalidCharacter(ch);
}
Пример #9
0
    void ChunkedReader::onSize()
    {
      char ch = _ib->sbumpc();

      log_trace("onSize, ch=" << charToPrint(ch));

      if (ch >= '0' && ch <= '9')
      {
        _chunkSize = _chunkSize * 16 + (ch - '0');
      }
      else if (ch >= 'a' && ch <= 'f')
      {
        _chunkSize = _chunkSize * 16 + (ch - 'a' + 10);
      }
      else if (ch >= 'A' && ch <= 'F')
      {
        _chunkSize = _chunkSize * 16 + (ch - 'A' + 10);
      }
      else
      {
        log_debug("chunk size=" << _chunkSize);

        if (ch == '\r')
        {
          _state = &ChunkedReader::onEndl;
        }
        else if (ch == '\n')
        {
          if (_chunkSize > 0)
            _state = &ChunkedReader::onData;
          else
            _state = 0;
        }
        else
        {
          _state = &ChunkedReader::onExtension;
        }
      }
    }
Пример #10
0
    void ChunkedReader::onBegin()
    {
      char ch = _ib->sbumpc();

      log_trace("onBegin, ch=" << charToPrint(ch));

      if (ch >= '0' && ch <= '9')
      {
        _chunkSize = ch - '0';
        _state = &ChunkedReader::onSize;
      }
      else if (ch >= 'a' && ch <= 'f')
      {
        _chunkSize = ch - 'a' + 10;
        _state = &ChunkedReader::onSize;
      }
      else if (ch >= 'A' && ch <= 'F')
      {
        _chunkSize = ch - 'A' + 10;
        _state = &ChunkedReader::onSize;
      }
      else
        throwInvalidCharacter(ch);
    }