Salve sto provando ad inviare dati ad uno script php
la creazione della socket e la connessione col server funziona,
il problema sono i dati che invio, perche come risposta ottengo:
codice:HTTP/1.1 400 Bad RequestDate: Mon, 16 Apr 2018 14:03:37 GMT Server: Apache/2.4.6 (CentOS) PHP/5.4.16 Content-Length: 226 Connection: close Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>400 Bad Request</title> </head><body> <h1>Bad Request</h1> <p>Your browser sent a request that this server could not understand.<br /> </p> </body></html>
qui i dati che invio
codice:string pHeader; string varPHP1 = "user-name=name"; string varPHP2 = "&user-password=pass"; string FormAction = "/folder/file.php"; int ContentLength = varPHP1.length() + varPHP2.length(); pHeader += "POST / HTTP/1.1\r\n"; pHeader += FormAction + "\r\n"; pHeader += varPHP1 + varPHP2 + "\r\n"; pHeader += "Host: " + host + "\r\n"; pHeader += "Content-Type: application/x-www-form-urlencoded\r\n"; pHeader += "User-Agent: test\r\n"; pHeader += "Content-Length: " + to_string(ContentLength) + "\r\n\r\n";
qualcuno sa dirmi dov'è che sbaglio?

Rispondi quotando