envoyproxy/envoy

refactor HeaderParser to make implementation of formatters easier/saner

Open

#4,221 创建于 2018年8月21日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)C++ (5,373 fork)batch import
help wanted

仓库指标

Star
 (27,997 star)
PR 合并指标
 (平均合并 8天) (30 天内合并 378 个 PR)

描述

Currently HeaderParser::configure (via the parserInternal helper method) splits a string into fixed and dynamic HeaderFormatter implementations, but delegates parsing of the dynamic HeaderFormatter arguments to the actual Formatter. In practice this means each Formatter has to do its own argument parsing when most of them will likely just take a single string.

I propose to modify the constructor for RequestInfoHeaderFormatter to take a formatter name (e.g., "START_TIME", "UPSTREAM_METADATA", "PROTOCOL", etc...) and a collection of 0 or more string arguments. This will allow us to push the parsing of arguments down into HeaderParser::configure/parseInternal. Initially we'll accept the existing "JSON array of strings" and unquoted string arguments used by UPSTREAM_METADATA and START_TIME. We'll add a quoted string (with appropriate backslash de-escaping) that can be used interchangeably with the unquoted string for single-argument formatters.

Doing this will make it possible to adopt an alternative to the clunky JSON array syntax for formatters that take 2 or more arguments, although I don't purpose to do that at this point.

Relevant Links: #4148.

贡献者指南