Mixed results with CGI

Dave Cragg dcragg at lacscentre.co.uk
Sun Aug 25 05:22:02 EDT 2002


At 10:56 pm -0700 24/8/02, Richard Gaskin wrote:
>With this script on the server:
>
>#!mc
>on startup
>    if $REQUEST_METHOD is "POST" then
>     read from stdin until empty
>     put it into buffer
>     put "Content-Type: text/plain" & cr
>     put "Content-Length:" && the length of buffer & cr & cr
>     put buffer
>    end if
>end startup
>
>And this script in a local stack:
>
>on mouseUp
>   put "data=" & urlEncode( fld "s") into tData
>   post tData to url "http://www.fourthworld.net/cgi-bin/t.mt"
>   put it into fld "r"
>end mouseUp
>
>
>...sometimes I get data returned from the server as expected, other times
>"it" is empty.
>
>I'm using the latest version of libURL downloaded from runrv.com, under MC
>2.4.3 build number 3.
>
>Any clues on why it's sometimes working and sometimes not?

To check if the problem is at the client or server end, you should 
check the result of the post statement.

  post tData to url "http://www.fourthworld.net/cgi-bin/t.mt"
  if the result is empty then
   put it into fld "r"
  else
   answer the result
  end if

Also, to test if data is getting read in at the server end, you could 
add a line like this.

     read from stdin until empty
     put it into buffer
     put "EXTRA DATA" before buffer
     put "Content-Type: text/plain" & cr
     put "Content-Length:" && the length of buffer & cr & cr
     put buffer


Cheers
Dave



More information about the metacard mailing list