Skip to content

是否有C语言版本http3 api使用示例呢? #280

Discussion options

You must be logged in to vote
  1. 应用层无需构造http3_headers_t,此结构体内部细节应用层无需关注(构造和解析均由TQUIC协议栈完成),应用程序在回调on_stream_headers函数内,调用http3_for_each_header解析http3_headers_t对象即可,TQUIC协议栈会通过http3_for_each_header入参中的cb回显每个头域细节(name-value及各自的长度)。
  2. 应用层发送HTTP/3头域(请求或响应)时,需要先将应用层的头域集合转换为http3_header_t数组,然后调用http3_send_headers接口写入TQUIC协议栈;发送头域逻辑编写示例,仅供参考(以下代码是C++编写,部分内容省略):

struct HeaderBuffer {
  unsigned off = 0;
  char buf[UINT16_MAX];
};

// Set offset for HTTP/3 header
static inline void QuicHeaderSetOffset(http3_header_t *hdr, char *buf, size_t name_len,
                                       size_t val_len) {
  memset(hdr, 0, sizeof(*hdr));
  hdr->name = reinterpret_cast<uint8_t *>(buf);
  hdr->name_len = name_len;
  hdr->value = re…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by iyangsj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants