您当前的位置: 首页 >  websocket

qianbo_insist

暂无认证

  • 0浏览

    0关注

    399博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

websocket协议中获取 http 请求字符串

qianbo_insist 发布时间:2021-02-14 11:53:32 ,浏览量:0

得到http协议首部字节示例 目的

根据RFC6455 文档 制作websocket server过程中,常常要得到首部url字符串,以便知道路由到哪里,参数是什么

http 请求字符串 格式
GET /live/1001 HTTP/1.1
Host: 127.0.0.1:9000
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: http://127.0.0.1:8000
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8
Cookie: Hm_lvt_db1838bfd0b81ebff469f5ef62a0621a=1612083606
Sec-WebSocket-Key: BxCqoG8QZJqG2AHS5tz2Ug==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
show me the code

1、用c代码

static int fetch_head_get(const char * lines, char *buf, int buflen)
{
	size_t l = strlen(lines);
	if (l             
关注
打赏
1663161521
查看更多评论
0.0486s