Example #1
0
int err_response(int fd, int status) {
    char buf[MAXBUF], body[MAXBUF], msg[LINESIZE];
    get_status_msg(status, msg);
    char date[256];
    sprintf(body, "<!DOCTYPE html><html><title>SWS Response</title>\r\n");
    sprintf(body, "%s<body>%d: %s\r\n", body, status, msg);
    sprintf(body, "%s May the force be with you.</body></html>\r\n", body);
    
    if (_simple_response !=1 ) {
        sprintf(buf, "HTTP/1.0 %d %s\r\n", status, msg);
        Send(fd, buf, strlen(buf),0);
        get_timestamp(date);
        sprintf(buf, "Date: %s\r\n",date);
        Send(fd, buf, strlen(buf), 0);
        sprintf(buf, "Server: Four0Four\r\n");
        Send(fd, buf, strlen(buf), 0);
        sprintf(buf, "Content-type: text/html\r\n");
        Send(fd, buf, strlen(buf), 0);
        sprintf(buf, "Content-length: %d\r\n\r\n", (int)strlen(body));
        Send(fd, buf, strlen(buf), 0);    
    }
    
    if (_head_response != 1)
        Send(fd, body, strlen(body), 0);
        
    return (int)strlen(body);
}
Example #2
0
void worker_engine::report_status() {
	auto asgn = get_current_assignment();
	if (asgn) {
		auto txt = asgn->get_status_msg();
		queue_for_send(publisher, txt);
	} else {
		// TODO: REPORT IDLE
	}
}