function _antispam_api_http_post in AntiSpam 6
Same name and namespace in other branches
- 7 antispam.module \_antispam_api_http_post()
Perform a HTTP POST request against the antispam server.
Parameters
string The request.:
string The antispam host, prefixed with the API key (except when checking for the key itself).:
string The path where to perform the request.:
Return value
array Headers in $response[0] and entity in $response[1].
4 calls to _antispam_api_http_post()
- antispam_api_cmd_comment_check in ./
antispam.module - AntiSpam API: Comment Check
- antispam_api_cmd_submit_ham in ./
antispam.module - AntiSpam API: Submit Ham
- antispam_api_cmd_submit_spam in ./
antispam.module - AntiSpam API: Submit Spam
- antispam_api_cmd_verify_key in ./
antispam.module - AntiSpam API: Key Verification
File
- ./
antispam.module, line 2277
Code
function _antispam_api_http_post($request, $host, $path) {
$fsock_timeout = (int) variable_get('antispam_connection_timeout', 10);
$http_request = "POST {$path} HTTP/1.0\r\n" . "Host: {$host}\r\n" . "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" . 'Content-Length: ' . strlen($request) . "\r\n" . 'User-Agent: ' . ANTISPAM_API_USERAGENT . "\r\n" . "\r\n" . $request;
$response = '';
if (false !== ($fs = @fsockopen($host, ANTISPAM_API_PORT, $errno, $errstr, $fsock_timeout))) {
fwrite($fs, $http_request);
while (!feof($fs)) {
$response .= fgets($fs, 1160);
// One TCP-IP packet
}
fclose($fs);
$response = explode("\r\n\r\n", $response, 2);
}
return $response;
}