lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] netconn_recv issue


From: David Empson
Subject: Re: [lwip-users] netconn_recv issue
Date: Fri, 27 Aug 2010 10:11:20 +1200


----- Original Message ----- From: "am85" <address@hidden>
To: <address@hidden>
Sent: Thursday, August 26, 2010 8:29 PM
Subject: Re: [lwip-users] netconn_recv issue



Hi Kieran,
Thank you very much.

I'm trying to implement this code, but I have the same problem.

do
{
 netbuf_data(Buffer, (void *) &dataptr, &len);
 data = dataptr;

if( strncmp(data, "GET / ", 4 ) == 0 )
{
       /* Send home page: text only */
       netconn_write( RxConn, (char *)(file.data), file.len, NETCONN_COPY
);

The above strncmp is a problem. If you only compare 4 characters, this will match every data item starting with "GET" followed by a single space. This will intercept all GET statements, not just "GET /".

Even if you increased the length to 5, it won't help, because it will still match all GET statements with a pathname starting with a slash.

You also need to confirm that there is no more text after the forward slash, and in order to do that you need to detect the end of the HTTP request as you might not have received all of it yet.

}

 else if( strncmp(data, "GET /image1.gif", 15 ) == 0 )
{
       /* Send first picture */
       netconn_write( RxConn, (char *)(file.data), file.len, NETCONN_COPY
);
}

else if( strncmp(data, "GET /image2.gif", 15 ) == 0 )
{
       /* Send second picture */
       netconn_write( RxConn, (char *)(file.data), file.len, NETCONN_COPY
);
}
} while(netbuf_next(Buffer) == -1);


Thanks to the previous answers.

With regards,
am85




reply via email to

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