lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] HTTP packet cut in half


From: Tomáš Švec
Subject: [lwip-users] HTTP packet cut in half
Date: Wed, 5 Sep 2012 13:11:01 +0200

Hello,

I am having trouble getting a webserver to work. My initial inspiration was this simple RAW API example: http://lists.gnu.org/archive/html/lwip-users/2008-06/msg00036.html .LWIP version is 1.4.0. I successfully establish a TCP/IP connection, the chip even sends a response to the request, but the packet observed in Wireshark is "cut in half", which means a header is received with 6 bytes of 0 data as HTTP and THEN comes the content in a separate packet, but without any headers! (So the words "HTTP/1..." are considered MAC addresses, etc.) Here is the simplified code:

static char htmlText[] =
"HTTP/1.0 200 OK\r\n\
Content-type: text/html\r\n\
\r\n\
<html> \
<head><title>Example project</title></head> \
<body> \
Hello, World! \
</body> \
</html>";

err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
        // This function is called after TCP/IP connection establishment
tcp_recv(pcb, http_receive);
return ERR_OK;
}

err_t http_receive(void * arg, struct tcp_pcb * tpcb, struct pbuf * p, err_t err)
{
char *rq;
if (p != NULL)
{
rq = p->payload;
if (rq[0] == 'G' &&  rq[1] == 'E' && rq[2] == 'T' && rq[3] == ' ')
{
tcp_sent(tpcb, http_sent); // http_sent never gets called
tcp_write(tpcb, htmlText, sizeof(htmlText), 0);
}

tcp_recved(tpcb, p->len);

pbuf_free(p);
}
return ERR_OK;
}

Do you have any idea what's going on?

Best regards

Tomas

reply via email to

[Prev in Thread] Current Thread [Next in Thread]