[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] netconn_recv issue
From: |
am85 |
Subject: |
Re: [lwip-users] netconn_recv issue |
Date: |
Thu, 26 Aug 2010 23:55:36 -0700 (PDT) |
Hi David,
Thank you very much.
I start by strncmp(data, "GET /image1.gif", 15 ) == 0 ), I have the same
problem.
Here is the code:
do
{
netbuf_data(Buffer, (void *) &dataptr, &len);
data = dataptr;
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
);
}
else if( strncmp(data, "GET / ", 4 ) == 0)
{
/* Send home page: text only */
netconn_write( RxConn, (char *)(file.data), file.len, NETCONN_COPY
);
}
} while(netbuf_next(Buffer) != -1);
Thanks to the previous answers.
With regards,
am85
David Empson wrote:
>
>
> ----- 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
>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>
>
--
View this message in context:
http://old.nabble.com/netconn_recv-issue-tp29529860p29549946.html
Sent from the lwip-users mailing list archive at Nabble.com.