How to test a POST from cmd

mod_harbour es un módulo para Apache que permite correr tus PRGs directamente en la web!!!
Post Reply
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

How to test a POST from cmd

Post by Antonio Linares »

echo "hello world" | ./modharbour test.prg

whatever is written there ("hello world") becomes the AP_Body() from modharbour
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: How to test a POST from cmd

Post by Antonio Linares »

Testing it using C language:

test.c

Code: Select all | Expand

#include <stdio.h>
#include <string.h>

int main( int args, char * argv[] )
{
   char buffer[ 250 ];

   memset( buffer, 0, sizeof( buffer ) );
   read( fileno( stdin ), buffer, sizeof( buffer ) - 1 );
   printf( "%s\n\n", "Content-Type: text/html;" );
   printf( "%s", buffer );
   return 0;
}


gcc test.c -otest

finally to test it:

echo "Hello world" | ./test
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Re: How to test a POST from cmd

Post by Antonio Linares »

Simplest echo.prg

echo prg

Code: Select all | Expand

function Main()

   ? FReadStr( hb_GetStdIn(), 256 )

return nil


echo "Hello world" | echo.exe
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply