POSt sur localhost via Socket
Envoi de Luc le 23 Février 2007 00:07:18:
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 = "\015\012"; $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 () { chomp ; if (/([^ ]+)[ ]*/) { $resultat .= $1; } } print "Content-type: text/html\n\n"; print $resultat;
merci pour toute aide...
Réponses:
Répondre
|

|