$http_response_header \n"; } else { //set a flag so we know the file is open $open = "true"; //build the soap query from the sent data $xmsg = $HTTP_RAW_POST_DATA; //write the http headers fputs ($fp, "POST /search/beta2 HTTP/1.0\n"); fputs ($fp, "Host: api.google.com\n"); fputs ($fp, "Content-Type: text/xml\n"); fputs ($fp, "SOAPAction: \"urn:GoogleSearchAction\"\n"); fputs ($fp, "Content-length: ".strlen($xmsg)."\n\n"); //write the soap query fputs ($fp, $xmsg); //process the result while (!feof($fp)) { //get the next character $character=fGetC($fp); //wait until we hit xml if ($character=="<") { //return the character and the rest of the file to the client echo($character); fpassthru($fp); $open = "false"; break; } } //if socket hasnt been closed, close it if ($open == "true") { fclose ($fp); } } } ?>