Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Allow PUT requests with empty bodies

Michael Schurter
December 28, 2010 03:58PM
Hi Maxim,

Thanks for checking out my patch.

On Tue, Dec 28, 2010 at 6:06 AM, Maxim Dounin wrote:
> On Mon, Dec 27, 2010 at 04:44:39PM -0800, Michael Schurter wrote:
>
>> As of 0.8.54 nginx returns a 411 Length Required response upon
>> receiving a PUT with no Content-Length header. There is nothing in the
>> HTTP 1.1 RFC that disallows empty PUTs. "Content-Length: n" or
>> "Transfer-Encoding: chunked" are only required if there is a body.
>> Therefore I saw no reason for this check to exist and removed it to
>> permit our RESTful HTTP API to function as currently designed.
>>
>> PUTs with no body or Content-Length header seem to work as expected as
>> do PUTs with a Content-Length and body message.
>>
>> Any chance of getting this patch accepted into nginx 0.8?
>
> I tend to agree, at least this is in line with not-requiring
> entity-body on POSTs (0.7.25+).
>
> But this probably require patching dav module, it may not be
> prepared to handle PUT requests without entity-body (not sure, but
> should be checked).

Indeed an empty PUT causes the dav module to segfault with my patch
applied. Seems dav's put handler always expects there to be a
temporary file created, but nginx doesn't create temporary files when
no Content-Length/entity-body exists.

I wanted to avoid further changes to nginx's core http module, so I
added a check inside dav's put handler to special case empty PUT's. It
basically:

1. Checks to see if the temporary file exists
2. If it does: this isn't an empty PUT, follow the existing code path
2. If the temporary file is null: create an empty file or truncate an
existing one

This is my first foray into nginx's code base, so I'm sorry if it's
not the right solution. Feedback is greatly appreciated as I'd love to
get proper empty PUT support into nginx.

Thanks,
Michael Schurter

(I also created a mercurial repo for my changes. I'm sure git is
preferred, but this repo is mainly for personal use. Let me know if
there's a public repo I should be basing patches against.)
https://bitbucket.org/schmichael/nginx
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Allow PUT requests with empty bodies

Michael Schurter 3817 December 28, 2010 05:02AM

Re: [PATCH] Allow PUT requests with empty bodies

Maxim Dounin 981 December 28, 2010 09:08AM

Re: [PATCH] Allow PUT requests with empty bodies

Michael Schurter 981 December 28, 2010 03:58PM

Re: [PATCH] Allow PUT requests with empty bodies

Michael Schurter 1301 December 28, 2010 09:00PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 313
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready