提问人:cj- 提问时间:9/24/2022 最后编辑:katnisscj- 更新时间:9/24/2022 访问量:43
llparse 具有多个代码点的 peek() 字符
llparse peek() characters with multiple code points
问:
我正在尝试修改 llhttp,一个基于 llparse 的 HTTP 客户端,以支持 NTRIP(一种基于 HTTP 的协议)。为此,我需要查看(匹配但不消费)并执行测试,否则启动跨度。'\u{D3}'
该问题仅适用于单个字符,并计为 2 ()。如何查看多个字符或重新预置第一个字符?peek()
'\u{D3}'
'\u{C3}\u{93}'
这是我所拥有的:
n('header_field_start') // Match node
.match('\r', n('headers_almost_done'))
.peek('\n', n('headers_almost_done'))
.peek(
'\u{D3}', // 2 characters
this.testLenientFlags(
LENIENT_FLAGS.NTRIP,
{
1: this.invokePausable('on_chunk_complete', ERROR.CB_CHUNK_COMPLETE, 'message_done') // If NTRIP is set
},
p.error(ERROR.INVALID_VERSION, 'Invalid major version') // Otherwise
)
)
.otherwise(span.headerField.start(n('header_field')));
// Defined earlier...
private testLenientFlags(flag: LENIENT_FLAGS, map: { [key: number]: Node }, next?: string | Node): Node {
const p = this.llparse;
const res = p.invoke(p.code.test('lenient_flags', flag), map);
if (next !== undefined) {
res.otherwise(this.node(next));
}
return res;
}
答: 暂无答案
评论