Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http_conn::parse_request_line(char *text)函数中直接在缓存区内拼接judge.html不会造成m_version内容被覆盖吗? #286

Open
Yolo-9527 opened this issue Jul 17, 2024 · 1 comment

Comments

@Yolo-9527
Copy link

http_conn::parse_request_line(char *text)函数中直接在缓存区内拼接judge.html不会造成m_version内容被覆盖吗?

@diandengpao
Copy link

diandengpao commented Sep 14, 2024

经测试 会的。测试代码如下

void requestLineForC() {

    char str[] = "GET / HTTP/1.1\0\0";    //提前将\r\n 注为 \0\0
    
    //------------------------------------
    char* url = strpbrk(str, " \t");
    
    if (!url) {
        cout << "报文有误" << endl;
        return;
    }
        
    *url++ = '\0';
    url += strspn(url, " \t");

    char* method = str;
    
    //------------------------------------
    
    char* version = strpbrk(url, " \t");
    
    if (!version) {
        cout << "报文有误" << endl;
        return;
    }

    *version++ = '\0';
    version += strspn(version, " \t");

    
    //至此 分割完毕------------------------
    if (strlen(url) == 1)
        strcat(url, "judge.html");    // cat: 将 judge.html 追加到 m_url中

    
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants