Re: [users@httpd] 回复: [users@httpd] how to get post data when using shell script as cgi script.

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

 



On Wed, Jan 3, 2018 at 11:14 PM, Keva-Slient <356730059@xxxxxx> 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

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux