src/server/daemon/protocol.c

changeset 23
a2c8fc23c90e
parent 21
627b09ee74e4
child 38
d07810b02147
equal deleted inserted replaced
22:adb0bda54e6b 23:a2c8fc23c90e
232 char *status_code_str = pool_malloc(pool, 8); 232 char *status_code_str = pool_malloc(pool, 8);
233 int sc_len = snprintf(status_code_str, 8, "%d ", rq->status_num); 233 int sc_len = snprintf(status_code_str, 8, "%d ", rq->status_num);
234 sbuf_write(out, status_code_str, sc_len); 234 sbuf_write(out, status_code_str, sc_len);
235 235
236 char *scmsg = pblock_findkeyval(pb_key_status, rq->srvhdrs); 236 char *scmsg = pblock_findkeyval(pb_key_status, rq->srvhdrs);
237 if(scmsg == NULL) {
238 scmsg = "OK";
239 }
237 sbuf_write(out, scmsg, strlen(scmsg)); 240 sbuf_write(out, scmsg, strlen(scmsg));
238 241
239 sbuf_write(out, "\r\n", 2); 242 sbuf_write(out, "\r\n", 2);
240 } 243 }
241 244
274 } 277 }
275 278
276 int http_start_response(Session *sn, Request *rq) { 279 int http_start_response(Session *sn, Request *rq) {
277 int fd = ((SystemIOStream*)sn->csd)->fd; 280 int fd = ((SystemIOStream*)sn->csd)->fd;
278 281
282 if(rq->status_num == -1) {
283 protocol_status(sn, rq, 200, "OK");
284 }
285
279 /* set socket blocking */ 286 /* set socket blocking */
280 int flags; 287 int flags;
281 flags = fcntl(fd, F_GETFL, 0); 288 flags = fcntl(fd, F_GETFL, 0);
282 fcntl(fd, F_SETFL, flags ^ O_NONBLOCK); 289 fcntl(fd, F_SETFL, flags ^ O_NONBLOCK);
283 290

mercurial