libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] largepost.c tutorial returns odd results


From: address@hidden
Subject: Re: [libmicrohttpd] largepost.c tutorial returns odd results
Date: Thu, 23 Aug 2012 01:41:32 +0200

Hey Christian,

Thanks for fixing that!  One other little thing about largepost.c:

In answer_to_connection for the if if (0 != *upload_data_size) {...} else 
{...}, the file pointer in con_info is still open when it goes to the else 
statement.  In the else statement, before the call to send_page, should be 
something like:

if (con_info->fp)
  fclose (con_info->fp)
// Now it is safe to open and inspect the file before calling send_page with a 
response

All the best,
~Mike

On 14 août 2012, at 20:39, Christian Grothoff <address@hidden> wrote:

> Hi!
> 
> I've fixed it in SVN 23236. The page was stack-allocated, in which case 
> MUST_COPY instead of PERSISTENT must be used in the option to create the 
> response.
> 
> Happy hacking!
> 
> Christian
> 
> On 08/14/2012 08:06 PM, address@hidden wrote:
>> Hey Christian,
>> 
>> Thanks for your quick reply!
>> 
>> I think the error has to do with how sprintf is being used.  If you pass a 
>> const char* to send_page all goes well.  I created a C++ version using 
>> std::string and that works fine too.
>> 
>> Cheers,
>> MS
>> 
>> On 14 août 2012, at 19:18, Christian Grothoff<address@hidden>  wrote:
>> 
>>> Dear Mike,
>>> 
>>> I've added the missing #includes to make all examples compile without 
>>> warnings on my system.
>>> 
>>> I've also been able to reproduce your error with the largepost.c example.  
>>> I'll try to look into it more later tonight (as it is not obvious to me 
>>> what is wrong).
>>> 
>>> 
>>> Happy hacking!
>>> 
>>> Christian
>>> 
>>> On 08/14/2012 05:40 PM, address@hidden wrote:
>>>> Hey all,
>>>> 
>>>> I've been stepping through all the tutorials and running them from Google 
>>>> Chrome using localhost:8888.  Everything works well until I get to 
>>>> largepost.c, which produces strange results instead of displaying the 
>>>> contents of askpage.  Is anyone else having this issue?  I could step 
>>>> through the example to try to find the cause but I'm hoping that someone 
>>>> more conversant in libmicrohttpd than I can spot it right away.
>>>> 
>>>> Also, one suggestion for the tutorials - it'd be great if all the right 
>>>> header files could be included in the tutorials so that they work out of 
>>>> the box.  Both simplepost.c and largepost.c, for example, need stdlib.h, 
>>>> stdio.h and string.h to compile w/ no errors or warnings.
>>>> 
>>>> Cheers,
>>>> MS
>>> 
>> 
> 
> 




reply via email to

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