On Wed, Jan 3, 2018 at 11:14 PM, Keva-Slient <[email protected]> wrote:

> thank you very much. in my work, i just need implementing an url
> interface.  in the beginning, the interface accept one parameter with only
> one value in url. but now, we want to put more than one value into that
> parameter. as the length of url is limited, i'm trying to transport that
> parameter with multiple values within http body.
>
> in my simple scene, using shell script is acceptable.
> do you know how to get http request body from shell script?
>

Using a shell script to handle a HTTP request is not acceptable from a
security standpoint. Let alone with respect to implementing a robust
solution that will work correctly when invoked with arbitrary input. Do not
try to write a robust HTTP request handler using a sh/bash/zsh/ksh script.
It cannot be done as a practical matter. Yes, it can be done theoretically
but that isn't realistic in any real world situation.

The HTTP POST data is available on the stdin stream of your shell script.
See
https://www.unix.com/shell-programming-and-scripting/232805-parsing-http-post-request.html
for one of many questions about how to deal with HTTP POST requests in
shell scripts.

I say again: Do not do this! Even if your HTTP POST API is only visible
within your organization (rather than visible publicly on the Internet)
this is a really bad idea. You need to use a language like Python which has
robust handling of HTTP requests when invoked via the CGI protocol.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

Reply via email to