warmcat / libwebsockets

canonical libwebsockets.org networking library
https://libwebsockets.org
Other
4.67k stars 1.46k forks source link

Question: how to parse custom header in the http2 lws client? #2991

Closed MengXii closed 8 months ago

MengXii commented 8 months ago

Example,In http/1.1, I can

case LWS_CALLBACK_RECEIVE_CLIENT_HTTP: { 
  if (lws_hdr_custom_length (wsi, "dnt:", 4) < 0) {
     // xxx 
  } else { 
   char value[32];
    auto n = lws_hdr_custom_copy(wsi, value, sizeof(value), "dnt:", 4); 
  } 
} 
lws-team commented 8 months ago

Looking at the related sources (lib/roles/http/parsers.c:598), it's not supported for h2 in lws.

MengXii commented 8 months ago

thanks

sikalyur commented 3 months ago

Is there any other way to read custom headers for http/2 connection in http server or it is impossible for now?

lws-team commented 3 months ago

Obviously h2 does parse headers in order to function, you can add headers to the list of tokens that knows and regenerate the parsing table so it treats them as normal headers.