How to test a POST from cmd

mod_harbour es un módulo para Apache que permite correr tus PRGs directamente en la web!!!

How to test a POST from cmd

Postby Antonio Linares » Tue Jan 04, 2022 1:02 pm

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: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to test a POST from cmd

Postby Antonio Linares » Tue Jan 04, 2022 3:15 pm

Testing it using C language:

test.c
Code: Select all  Expand view
#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: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to test a POST from cmd

Postby Antonio Linares » Tue Jan 04, 2022 8:29 pm

Simplest echo.prg

echo prg
Code: Select all  Expand view
function Main()

   ? FReadStr( hb_GetStdIn(), 256 )

return nil


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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to mod_harbour

Who is online

Users browsing this forum: No registered users and 3 guests