http response to GET request - working in FF not Chromium

Posted by Tyler on Stack Overflow See other posts from Stack Overflow or by Tyler
Published on 2010-04-02T21:16:59Z Indexed on 2010/04/02 21:23 UTC
Read the original article Hit count: 321

Filed under:
|
|

For fun I'm trying to write a very simple server in C.

When I send this response to Firefox it prints out the body "hello, world" but with Chromium it gives me a Error 100 (net::ERR_CONNECTION_CLOSED): Unknown error.

This, I believe, is the relevant code:

char *response = "HTTP/1.0 200 OK\r\nVary: Accept-Encoding, Accept-Language\r\nConnection: Close\r\nContent-Type: text/plain\r\nContent-Length:20\r\n\r\nhello, world";
    if(send(new_fd, response, strlen(response), 0) == strlen(response)) {
        printf("sent\n");   
    };

    close(new_fd);

What am I missing?

Thanks!

© Stack Overflow or respective owner

Related posts about c

    Related posts about network-programming