lua-users home
lua-l archive

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


I wouldn't call this a bug. It is a feature request. A bug is something
that behaves differently from specification.
I agree that a SHOULD is not a MUST but still believe that SHOULDs
should be implemented unless there is a specific reason not to, but
then again it's just my personal opinion, it is juat a SHOULD not a

I gave the reason: http.request does not know the content-type of the
request body. Only the programmer knowns. Therefore, LuaSocket doesn't
send the header by magic.

Either I change the simple API (thus making it complicated), or I just
drop it.  I will probably drop the simple API for POST. Whoever is
coding a POST might as well just write his own wrapper over the complex
API and send the header.

for compatibility with HTTP/1.0 yes it has to, but in HTTP/1.1 it does
not not necesarily have to be there, in some  are cases in it MIGHT or
MUST NOT not be there (4.4 explains when) and the RFC implicitly tells
that in some parts it  should not be used.

Once you read the RFC for the 23213123'rd time, you forget the wording
and remember only the reasoning behiind things.

The server needs to know where the request body ends. HTTP uses one of
three ways to define the length of a message: connection close,
content-type, or chunked.  In the case of a POST, the client
can't close the connection, because it wants to read the response. It
can't send chunked, because most servers won't accept it. By exclusion,
the content-length has to be there.

Try passing a source as the body to the complex http.request function
and try not giving a content-length field. You will see I try sending
chunked. At this point, there is nothing else I can do.

In the simple API, I get a string. I have its length. So it's a piece of
cake: send content-length. Servers will be happy all over the place.

But anyway I still believe (an Opinion Report if you want to consider
it that way) that a Content-Type should be provided.

Nobody is questioning this fact. What I am saying is that it's not up to
LuaSocket to add this header behind your back. It is up to the LuaSocket
user to add the correct header.