Welcome! Log In Create A New Profile

Advanced

Re: Bug in handling POST then sending a file back

Saint Michael
January 08, 2024 04:54PM
This is for an API, so no browsers are or will be involved.
So, I should print binary information from my LUA script?
A second question, can I offload receiving a very large zip file to
NGINX? I just need to know in my LUA script when it has fully arrived
and the name assigned to it.
Many thanks for your help. The Openresty Slack app hasn't helped a bit.

On Mon, Jan 8, 2024 at 3:50 PM Maxim Dounin <mdounin@mdounin.ru> wrote:
>
> Hello!
>
> On Sun, Jan 07, 2024 at 09:41:33PM -0500, Saint Michael wrote:
>
> > I am using openresty and nginx.
> > I send a file to the server, which is a POST operation. Then the
> > server processes the file and needs to send back a different file. I
> > try to send a file with ng.exec("/static/file_name") and I get error
> > 405 Not Allowed.
> > But if I do a 302 redirect, it works.
> > I imagine that Nginx feels bad about sending a file in a POST
> > operation, but http does not have such a limitation.
> > Is there a workaround for this?
>
> As far as I can see from the Lua module docs, ngx.exec() you are
> using in your script does an internal redirect. As the result,
> nginx ends up with a POST request to a static file, which is not
> something nginx can handle: it does not know what to do with data
> POSTed to a static file, hence the error.
>
> If you've already processed POSTed data, and want to show some
> static message to a client, consider returning a redirect to the
> static file to the user, such as 303 (See Other), see
> https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303 for a
> good description.
>
> If you are sure you want to return the file as a response to the
> POST request itself (this is generally a bad practice, since it
> will break page refresh and browser history navigation), consider
> returning the file directly from your script instead of trying to
> do an internal redirect.
>
> --
> Maxim Dounin
> http://mdounin.ru/
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> https://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Bug in handling POST then sending a file back

Saint Michael January 07, 2024 09:44PM

Re: Bug in handling POST then sending a file back

Maxim Dounin January 08, 2024 03:52PM

Re: Bug in handling POST then sending a file back

Saint Michael January 08, 2024 04:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 289
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