POST en perl sur localhost via Socket

Fermé
Luc - 23 févr. 2007 à 00:18
lami20j Messages postés 21331 Date d'inscription jeudi 4 novembre 2004 Statut Modérateur, Contributeur sécurité Dernière intervention 30 octobre 2019 - 24 févr. 2007 à 21:53
Voilà, je cherche à passer un POST depuis un CGI perl vers un script php sur la même machine. Le CGI recoit lui même un POST, effectue des traitements et recompose une chaine de données à passer en POST à un script php. Avant de poster vers le php, tout va encore bien, mais en arrivant à la page php, je n'ai rien reçu ...

Voici l'envoi du POST coté perl :

$host = 'localhost';
$crlf = "52";
$http = "POST $php_script HTTP/1.0$crlf".
"Host: $host$crlf".
"Referer: %ENV(HTTP_REFERER)$crlf".
"User-Agent: %ENV(HTTP_USER_AGENT)$crlf".
"Connection: close$crlf".
"Content-Type: application/x-www-form-urlencoded$crlf".
"Content-Length: 40$crlf$crlf".
"test1=valeur1&test2=valeur2";

$tcp = getprotobyname('tcp') or die "getprotobyname\n";
$hosti = inet_aton($host) or die "inet_aton\n";
$hosts = sockaddr_in(80, $hosti);
socket(SOK, PF_INET, SOCK_STREAM, $tcp) or die "socket\n";
connect(SOK, $hosts) or die "connect\n";
select SOK; $| = 1; select STDOUT;
print SOK $http;

$resultat = "";
while (<SOK>) {
chomp ;
if (/([^
]+)[
]*/) {
$resultat .= $1;
}
}
print "Content-type: text/html\n\n";
print $resultat;


merci pour toute aide...

1 réponse

lami20j Messages postés 21331 Date d'inscription jeudi 4 novembre 2004 Statut Modérateur, Contributeur sécurité Dernière intervention 30 octobre 2019 3 567
24 févr. 2007 à 21:53
Salut,

quand tu utilises une regex de cette manière
/([^
]+)[
]*/)

il faut employer le modificateur /x
/([^
]+)[
]*/x
0