(Perl) HTTP POST with Binary Data in Request Body
Do an HTTPS POST with a binary request body.
use chilkat();
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
$http = chilkat::CkHttp->new();
$fac = chilkat::CkFileAccess->new();
$reqBody = chilkat::CkByteData->new();
$success = $fac->ReadEntireFile("qa_data/pdf/helloWorld.pdf",$reqBody);
$responseStr = $http->postBinary("https://example.com/something",$reqBody,"application/pdf",0,0);
if ($http->get_LastMethodSuccess() == 0) {
print $http->lastErrorText() . "\r\n";
exit;
}
$responseStatusCode = $http->get_LastStatus();
print "Status code: " . $responseStatusCode . "\r\n";
# For example, if the response is XML, JSON, HTML, etc.
print "response body:" . "\r\n";
print $responseStr . "\r\n";
|