libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] requests without Content-Length HTTP header


From: Christian Grothoff
Subject: Re: [libmicrohttpd] requests without Content-Length HTTP header
Date: Fri, 31 Jan 2014 12:48:40 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10

On 01/31/2014 12:37 PM, Ken Zangelin wrote:
> Hi again!
> 
> So, if I understand this correctly, my server will have to demand either
> the
> 'Content-Length' or the 'Transfer-Encoding' header in any incoming request.

Yes.

> I was hoping I could accept requests without any length detail at all.
> Something like, if after a timeout of X milliseconds, the incoming package
> is considered complete, or even better, let the MHD client inform the
> MHD library
> that the incoming package is complete - passing it the payload as it
> comes in.

That's not possible, as then MHD cannot tell if/when the transmission is
finished.  And half-closing the stream by the client would not work, as that
might also be an error and would (according to the spec) not allow us to
answer anymore.

> Right now with my tests without any of these two headers (PUT and POST)
> I get no payload at all in the callback function.
> I'm guessing MHD treats this case at 'Content-Length: 0'.

That is possible.

> Any interest in implementing something like this?

I do not think what you are proposing would be compliant with the HTTP
specification for the reasons stated above, and thus it would not be a
good idea.  Implementing chunking on the client-side should be pretty
easy and will address your problems, and with much less latency compared
to using timeouts.


Happy hacking!

Christian

> Thanks for the quick reply!
> 
> /Ken Z
> 
> On 31/01/14 12:12, Christian Grothoff wrote:
>> Hi!
>>
>> This is not a known limitation, it should be possible to receive POST/PUT
>> requests of unknown size / without length header.  Note that in this
>> case,
>> the client must use 'chunked' encoding for the upload (but MHD will strip
>> the encoding, so you as the application will still only get the payload
>> without the chunking).
>>
>>
>> Happy hacking!
>>
>> Christian
>>
>> On 01/31/2014 09:51 AM, Ken Zangelin wrote:
>>> Hi there,
>>>
>>> I use MHD for a REST server and I'm experiencing problems to receive the
>>> payload for incoming requests that have no Content-Length HTTP header.
>>> Is this a known 'limitation' of MHD or is it me doing something wrong?
>>>
>>> Thank you,
>>>
>>> /Ken Z
>>>
>>>
>>> ________________________________
>>>
>>> Este mensaje se dirige exclusivamente a su destinatario. Puede consultar
>>> nuestra política de envío y recepción de correo electrónico en el enlace
>>> situado más abajo.
>>> This message is intended exclusively for its addressee. We only send and
>>> receive email on the basis of the terms set out at:
>>> http://www.tid.es/ES/PAGINAS/disclaimer.aspx
>>>
> 
> 
> ________________________________
> 
> Este mensaje se dirige exclusivamente a su destinatario. Puede consultar
> nuestra política de envío y recepción de correo electrónico en el enlace
> situado más abajo.
> This message is intended exclusively for its addressee. We only send and
> receive email on the basis of the terms set out at:
> http://www.tid.es/ES/PAGINAS/disclaimer.aspx
> 



reply via email to

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