Q: Cprog running as a cgi having probles with post-method

Q: Cprog running as a cgi having probles with post-method

Post by Jorn Gabrielse » Tue, 17 Jun 1997 04:00:00



Dear Sirs.

I have a question. How do I get the QUERY_STRING in a C prog, running as a
cgi on a unix, when the method "post" is uset?
When I use getenv("QUERY_STRING"), it only seems to work when the
get-method is
used, and I just get a NULLpointer when I use the post-method

Yours Faithfully
Jorn-T. Gabrielsen


Yours Faithfully
Jorn-T. Gabrielsen


Homepage: http://www.krs.hia.no/~jgabriel/

 
 
 

Q: Cprog running as a cgi having probles with post-method

Post by Andrew Giert » Tue, 17 Jun 1997 04:00:00


 Jorn> Dear Sirs.
 Jorn> I have a question. How do I get the QUERY_STRING in a C prog,
 Jorn> running as a cgi on a unix, when the method "post" is uset?

POST data isn't supplied in the environment, but as the standard
input to the script instead. (Environment space is limited on some
systems, and POST data can be large.)

--
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>

 
 
 

Q: Cprog running as a cgi having probles with post-method

Post by Frederick Barne » Mon, 23 Jun 1997 04:00:00



> I have a question. How do I get the QUERY_STRING in a C prog, running as a
> cgi on a unix, when the method "post" is uset?
> When I use getenv("QUERY_STRING"), it only seems to work when the
> get-method is
> used, and I just get a NULLpointer when I use the post-method
> Jorn-T. Gabrielsen

When the post method is used, the data is sent in through stdin, not
through an enviroment variable.

An enviroment variable should be set, I think it's called
'REQUEST_METHOD'. If it's 'GET' then read out of the variable
QUERY_STRING, if it's post, you'll need to read out of stdin. Somtimes the
variable CONTENT_LENGTH will be set as well, so you know how much you need
to cope with.

Hope this helps a bit,
Fred.

+----------------------------------------------------oOOo--oOOo----+
| Fred Barnes, CS Student, Canterbury, UK.                         |

| http://stue030/ (UKC only)  http://www.geocities.com/~dr_barnes/ |
+------------------------------------------------------------------+

 
 
 

1. CGI scripts: how to read data from post-method

Hi there!
I installed Apache quite well.
and now I am trying to evaluate some form data with a simple CGI-script.
But it works not as expected.
data being  send via get come in the right variable
but if I try to get data via the post-method I don't know how to handle
them in a simple Bourne-shell script. where from must I get data from
stdin in a bsh?

thanks Wolfgang

2. memory panic

3. Server misconfig when using POST-method in CGI-scripts

4. Netscape browser crashes frequently

5. CGI "newbie" and change unix password method="POST"

6. starting X corrupts display

7. Apache error: "Method not allowed" POST CGI

8. Metric/Standard Conversion for X

9. apache - The requested method POST is not allowed for the URL /main.cgi

10. Parsing CGI data (POST method) in ksh

11. CGI POST Method and Referring Host?

12. User Authentation with method=POST CGI script

13. POST method in CGI to Apache 1.2B7 gives error!