10_custom_parsers.qbk 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. [/
  2. Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. Official repository: https://github.com/boostorg/beast
  6. ]
  7. [section Custom Parsers]
  8. While the parsers included in the library will handle a broad number of
  9. use-cases, the __basic_parser__ interface can be subclassed to implement
  10. custom strategies for storing parsed results: the basic parser processes
  11. input buffers into elements according to the HTTP/1 protocol specification,
  12. while the derived class decides what to do with those elements. Custom parsers
  13. will work with all of the HTTP stream read algorithms, as those algorithms use
  14. only the basic parser interface. Some use cases for implementing custom
  15. parsers are:
  16. * Inspect incoming header fields and keep or discard them.
  17. * Use a container provided by an external interface.
  18. The basic parser uses virtual functions. To declare your user-defined parser,
  19. derive from __basic_parser__ and implement all the required virtual functions.
  20. A declaration for the derived class may look like this:
  21. [code_http_10_custom_parser]
  22. [endsect]