libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Problem about MHD post processor


From: Christian Grothoff
Subject: Re: [libmicrohttpd] Problem about MHD post processor
Date: Tue, 04 Jun 2013 15:50:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12

You'd use the "MHD_set_connection_value" on your connection (once, just
before creating the post processor) with MHD_HEADER_KIND for
MHD_HTTP_HEADER_CONTENT_TYPE to the repective value (i.e.
MHD_HTTP_POST_ENCODING_{FORM_URLENCODED,MULTIPART_FORMDATA}.

Again, please do read http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4
as for multipart you need to specify the boundary in the value as well
(which would most likely be hard for you to determine on the server side;
so good luck if your client sends multipart data without the proper header).

Finally, please consider that you might just have forgotten to set "enctype=FOO"
in your <FORM> in the HTML.  So if you do that, your browser might send the 
data with the
proper encoding to begin with.  But again, that depends on the client. Again, 
please
read the HTTP spec (17.13.4) and look at the traffic you're sending and 
receiving.


Happy hacking!

Christian


On 06/04/2013 03:05 AM, wan_guangping wrote:
> Dear christian,
> Thank you very much!
> And you say that I could set the method manually before creating the post 
> processor, or if it is not one of those two 
> methods I have to do the parsing of the client output yourself. could you 
> please tell me how to set the method manually before creating the post 
> processor ,can you give me a emample to help me understand it 
> thoroughly.Thank you again for your patient guidance of me.
> 
> 2013-06-04
> 
> 
> 
> wan_guangping
> 
> 
> 
> 发件人:Christian Grothoff <address@hidden>
> 发送时间:2013-06-04 01:36
> 主题:Re: Problem about MHD post processor
> 收件人:"wan_guangping"<address@hidden>,"libmicrohttpd development and user 
> mailinglist"<address@hidden>
> 抄送:
> 
> On 06/03/2013 04:40 PM, wan_guangping wrote: 
>> Dear christian, 
>>  
>> I am very sorry to bother you again.I have implemented a HTTP server with 
>> your MHD(libmicrohttpd).But my HTTP server has a problem about POST/PUT 
>> operation.I test the example problem largepost.c ,I could get the right 
>> result when I use the curl command, 
>>  
>> curl -F "address@hidden;filename=test.jpg" 127.0.0.1:8888/postform, 
>>  
>> however,I cannot get the right result when I use other methods to send HTTP 
>> request,I just can get that the problem that : 
>>  
>> con_info->postprocessor = 
>>             MHD_create_post_processor (connection, 
>> POSTBUFFERSIZE,iterate_post, (void *) con_info); 
>>     if (NULL == con_info->postprocessor) 
>>     { 
>>         free (con_info); 
>>         return MHD_NO; 
>>     } 
>>  
>> ererytime it returns from here.The  MHD_create_post_processor have not been 
>> called  successfully. 
> 
> The post processor only supports URL and Multipart-encodings 
> (see http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4, and 
> #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED 
> "application/x-www-form-urlencoded" 
> #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data"). 
> 
> So if your browser / client uses a different method (or fails to specify 
> which 
> method it uses), MHD's post processor won't work.  You can then set the 
> method 
> manually before creating the post processor, or if it is not one of those two 
> methods you have to do the parsing of the client output yourself. 
> 
>> So I want to know ,in which case the  function MHD_create_post_processor  
>> will not be called rightly.I use MHD to implement a  REST server,and I use 
>> the Amazon S3 API to send HTTP request to PUT/POST objects.Every time the 
>> program failed because after the MHD_create_post_processor  called, 
>> con_info->postprocessor==NULL,Could you please help me to solve this problem 
>>  .Thank you very much. 
> 
> It is not that you're calling the create_post_processor the 'wrong' way, the 
> most 
> likely cause is an unspecified or unsupported POST encoding. 
> 
> Happy hacking! 
> 
> Christian 




reply via email to

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