340 |
340 |
341 // add header from rq->srvhdrs |
341 // add header from rq->srvhdrs |
342 add_http_response_header(out, rq); |
342 add_http_response_header(out, rq); |
343 |
343 |
344 // add connection header |
344 // add connection header |
345 char *conn_str = pblock_findkeyval(pb_key_connection, rq->headers); |
345 if(rq->rq_attr.keep_alive) { |
346 if(conn_str && !strcasecmp(conn_str, "keep-alive")) { |
|
347 sbuf_write(out, "Connection: keep-alive\r\n", 24); |
346 sbuf_write(out, "Connection: keep-alive\r\n", 24); |
348 pblock_kvinsert(pb_key_connection, "keep-alive", 10, rq->srvhdrs); |
347 pblock_kvinsert(pb_key_connection, "keep-alive", 10, rq->srvhdrs); |
349 rq->rq_attr.keep_alive = 1; |
|
350 } else { |
348 } else { |
351 sbuf_write(out, "Connection: close\r\n", 19); |
349 sbuf_write(out, "Connection: close\r\n", 19); |
352 pblock_kvinsert(pb_key_connection, "close", 5, rq->srvhdrs); |
350 pblock_kvinsert(pb_key_connection, "close", 5, rq->srvhdrs); |
353 } |
351 } |
|
352 |
354 |
353 |
355 // response header end |
354 // response header end |
356 sbuf_write(out, "\r\n", 2); |
355 sbuf_write(out, "\r\n", 2); |
357 |
356 |
358 // flush buffer to the socket |
357 // flush buffer to the socket |