POST en perl sur localhost via Socket
Luc
-
lami20j Messages postés 21331 Date d'inscription Statut Modérateur, Contributeur sécurité Dernière intervention -
lami20j Messages postés 21331 Date d'inscription Statut Modérateur, Contributeur sécurité Dernière intervention -
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...
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...
A voir également:
- POST en perl sur localhost via Socket
- Brouillon post instagram - Guide
- Post it windows - Télécharger - Agendas & Calendriers
- Code post - Télécharger - Vie quotidienne
- Post it sur mac - Forum MacOS
- Supprimer musique post instagram ✓ - Forum Instagram