The RFC is pretty clear, though maybe you missed it.

PHP and all other CGI/cgiwrap executables read CONTENT_LENGTH bytes from STDIN.

There's a fairly old Perl CGI tutorial which covers the details: http://www.abiglime.com/webmaster/articles/cgi/021098.htm and is easily translatable to C.

On 25 May 2011 12:01, maurizio beppo <fuitafuita@gmail.com> wrote:

Hi, i'm try to understand how message-body (http://www.faqs.org/rfcs/rfc3875.html) (like $_POST variable in php) is passed to execv().

Example:
I have a data in a form, like this
<form method=POST>
     <input type=text value="admin" name="login">
    <input type=pass value="123" name="passwd">
etc...
</form>

Cgiwrap make the environment (i put here the most important)

ENV: 'HTTP_USER_AGENT=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_6) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24'
ENV: 'CONTENT_TYPE=application/x-www-form-urlencoded'
ENV: 'HTTP_ACCEPT=application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'

ENV: 'CONTENT_LENGTH=119'
ENV: 'SERVER_SOFTWARE=Apache/2.2.14 (Unix)'
ENV: 'SCRIPT_FILENAME=/drupal2/index.php'
ENV: 'REDIRECT_QUERY_STRING=q=node&destination=node'
ENV: 'REDIRECT_URL=/drupal2/index.php'
ENV: 'GATEWAY_INTERFACE=CGI/1.1'
ENV: 'SERVER_PROTOCOL=HTTP/1.0'
ENV: 'REQUEST_METHOD=POST'
ENV: 'QUERY_STRING=q=node&destination=node'
ENV: 'REQUEST_URI=/drupal2/?q=node&destination=node
ENV: 'SCRIPT_NAME=/drupal2/index.php'

and after do somethig like

 execv("/path/php", {"/path/php", "/doc/index.php",NULL})

My problem is to understand: where is message-body ??
i do this:
 /* Execute the script */
  DEBUG_Msg("\n\n");
  DEBUG_Msg("Output of script follows:");
  DEBUG_Str("argv[0]:",Context.execPath);
  DEBUG_Str("argv[0]:",Context.execArgv[0]);
  DEBUG_Str("argv[1]:",Context.execArgv[1]);
  DEBUG_Str("argv[2]:",Context.execArgv[2]); // is --> NULL
  for(i = 0;*(environ+i);++i)
  DEBUG_Str("ENV:",*(environ+i));
  DEBUG_Msg("=====================================================");

and i can't find nothig about message-body in the environment.

How you can see, CONTENT_LENGTH=119, and message-body is somethig like
login=admin&pass=123&other=etc

How can php initialize his POST data ?

Please, can you help me ?

thank you very much


------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
cgiwrap-users mailing list
cgiwrap-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cgiwrap-users