il problema è semplicemente che devi mandare il doppio invio a capo "\r\n\r\n" solo dopo l'ultima riga dell'header non ad ogni riga.... il doppio invio a capo indica la separazione tra header e contenuto...
Prova così:
codice:
fprintf(cgiOut, "Content-type: %s\r\n", "application/x-download");
fprintf(cgiOut, "Content-Disposition: attachment; filename=%s;\r\n", "prova.txt");
fprintf(cgiOut, "Accept-Ranges: bytes\r\n");
fprintf(cgiOut, "Content-Length: %d\r\n\r\n",70);
if( (stream = fopen( path, "rt" )) != NULL )
{
while( !feof( stream ) )
{
//leggo tutti i BYTE in una volta solo
numByte = fread( buffer, sizeof( char ), 500, stream );
buffer[70] = '\0';
fprintf(cgiOut,buffer);
if( ferror( stream ) )
return 0;
}
}
fclose( stream );