if (debug) log_d("initial left: %d", cn->left);
static int scan_request(struct connection *cn){	char *s;	int c, state;	s = cn->header_input.middle;	state = cn->header_input.state;	while (state != 8 && s < cn->header_input.end) {		c = *s++;		if (c == 0) {			log_d("read_connection: NUL in headers");			close_connection(cn);			return -1;		}		switch (state) {		case 0:			switch (c) {			default:				state = 1;				break;			case '\r':			case '\n':				break;			case ' ':			case '\t':				state = 2;				break;			}			if (state) {				gettimeofday(&cn->itv, 0);				set_connection_state(cn, HC_READING);			}			break;		case 1:			switch (c) {			default:				break;			case ' ':			case '\t':				state = 2;				break;			case '\r':				state = 3;				break;			case '\n':				state = 8;				break;			}			break;		case 2:			switch (c) {			case 'H':				state = 4;				break;			default:				state = 1;				break;			case ' ':			case '\t':				break;			case '\r':				state = 3;				break;			case '\n':				state = 8;				break;			}			break;		case 3:			switch (c) {			case '\n':				state = 8;				break;			default:				state = 1;				break;			case ' ':			case '\t':				state = 2;				break;			case '\r':				break;			}			break;		case 4:			switch (c) {			case '\r':				state = 5;				break;			case '\n':				state = 6;				break;			}			break;		case 5:			switch (c) {			default:				state = 4;			case '\r':				break;			case '\n':				state = 6;				break;			}			break;		case 6:			switch (c) {			case '\r':				state = 7;				break;			case '\n':				state = 8;				break;			default:				state = 4;				break;			}			break;		case 7:			switch (c) {			default:				state = 4;			case '\r':				break;			case '\n':				state = 8;				break;			}			break;		}	}	cn->header_input.state = state;	cn->header_input.middle = s;	if (state == 8) {		if (process_request(cn->r) == -1) {			if (cn->connection_state != HC_FORKED) {				close_connection(cn);				return -1;			}			return 0;		}		cn->left = cn->rfd == -1 ? 0 : cn->r->content_length;		if (fill_connection(cn) == -1) {			close_connection(cn);			return -1;		}		set_connection_state(cn, HC_WRITING);	}	return 0;}