Beispiel #1
0
void httpd_receive(struct http_state *http, const char *data, int len)
{
	while (len)
	{
		switch (http->state_client)
		{
		case HTTPD_CLIENT_REQUEST:
			httpd_receive_request(http, *data++);
			len--;
			break;
		case HTTPD_CLIENT_HEADER:
			httpd_receive_header(http, *data++);
			len--;
			break;
		case HTTPD_CLIENT_DATA:
		{
			int r = httpd_receive_data(http, data, len);
			data += r;
			len -= r;
			break;
		}
		default:
			data += len;
			len = 0;
		}
	}
	
	httpd_handle_server(http);
}
Beispiel #2
0
static void
send_data(struct tcp_pcb *pcb, struct http_state *http) {
    httpd_handle_server(http);
    int av = tcp_sndbuf(pcb), a = http->sendbuffer_write - http->sendbuffer_read;

    if (a < 0)
        a = SENDBUFFER_LEN - http->sendbuffer_read;

    if (av < a)
        a = av;

    http->sendbuffer_read += tcp_do_send(pcb, http->sendbuffer + http->sendbuffer_read, a);

    if (http->sendbuffer_read == SENDBUFFER_LEN)
        http->sendbuffer_read = 0;
}