Bug in handling POST then sending a file back
Saint Michael
venefax at gmail.com
Mon Jan 8 21:52:05 UTC 2024
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 at 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 at nginx.org
> https://mailman.nginx.org/mailman/listinfo/nginx
More information about the nginx
mailing list