Commit 6c888a8c0790f0a94471d029977ffd8426d7b416

Authored by Georg Hopp
1 parent a4d09213

now only use keep-alive....

@@ -64,7 +64,7 @@ get_data(void * _this, int fd) @@ -64,7 +64,7 @@ get_data(void * _this, int fd)
64 size_t remaining, chunks; 64 size_t remaining, chunks;
65 char buffer[1024]; 65 char buffer[1024];
66 66
67 - size_t size = read(fd, buffer, 1024); 67 + ssize_t size = read(fd, buffer, 1024);
68 68
69 if (0 < size) { 69 if (0 < size) {
70 remaining = this->buffer_used % HTTP_REQUEST_PARSER_READ_CHUNK; 70 remaining = this->buffer_used % HTTP_REQUEST_PARSER_READ_CHUNK;
@@ -99,6 +99,7 @@ serverRun(Server this) @@ -99,6 +99,7 @@ serverRun(Server this)
99 char timestr[200]; 99 char timestr[200];
100 100
101 #define RESP_HEAD "HTTP/1.1 404 Not Found\r\n" \ 101 #define RESP_HEAD "HTTP/1.1 404 Not Found\r\n" \
  102 + "Connection: Keep-Alive\r\n" \
102 "Content-Type: text/html\r\n" \ 103 "Content-Type: text/html\r\n" \
103 "Content-Length: %lu\r\n" \ 104 "Content-Length: %lu\r\n" \
104 "Date: %s\r\n" \ 105 "Date: %s\r\n" \
@@ -120,8 +121,8 @@ serverRun(Server this) @@ -120,8 +121,8 @@ serverRun(Server this)
120 * @TODO: just to send an answer and be able to make some 121 * @TODO: just to send an answer and be able to make some
121 * apache benchs i do it here...this definetly MUST BE moved 122 * apache benchs i do it here...this definetly MUST BE moved
122 */ 123 */
123 - sprintf((this->conns)[fd].wbuf, RESP_HEAD "\r\n" RESP_DATA, sizeof(RESP_DATA), timestr);  
124 - (this->fds)[i].events = (this->fds)[i].events | POLLOUT; 124 + sprintf((this->conns)[fd].wbuf, RESP_HEAD "\r\n" RESP_DATA, sizeof(RESP_DATA) - 1, timestr);
  125 + (this->fds)[i].events |= POLLOUT;
125 } 126 }
126 127
127 queue->nrequests = 0; 128 queue->nrequests = 0;
@@ -147,7 +148,8 @@ serverRun(Server this) @@ -147,7 +148,8 @@ serverRun(Server this)
147 "write error, closing connection"); 148 "write error, closing connection");
148 } 149 }
149 150
150 - serverCloseConn(this, i); 151 + //serverCloseConn(this, i);
  152 + (this->fds)[i].events &= ~POLLOUT;
151 } 153 }
152 else { 154 else {
153 memmove((this->conns)[fd].wbuf, 155 memmove((this->conns)[fd].wbuf,
Please register or login to post a comment