小编jmo*_*aal的帖子

http 1.0 保持活动服务器和 curl

我正忙于在嵌入式平台上实现自己的 http 服务器。从技术上讲,服务器符合 HTTP 1.0,因此它希望客户端发送标头“Connection: Keep-Alive”以保持连接打开。

实现看起来像这样。我删除了解析 HTTP 标头并执行请求的代码,以使帖子尽可能简短:

int Service_Request(int conn) {

    struct ReqInfo reqinfo;
    volatile int resource = 0;
    int retval = 0;
    Req_Result req_result = GOT_REQ;

    InitReqInfo(&reqinfo);

    /* while we still have HTTP requests to process */
    while (req_result == GOT_REQ)
    {

        /*  Get HTTP request, there are 3 different return values:
         * GOT_REQ: we got a valid HTTP request
         * TIMEOUT_REQ we timed out waiting for a request
         * ERROR_REQ there was some error receiving from …
Run Code Online (Sandbox Code Playgroud)

curl http keep-alive

1
推荐指数
1
解决办法
7417
查看次数

标签 统计

curl ×1

http ×1

keep-alive ×1