Send Data with a POST Method

You must send the DREADDDATA action using a POST request method. There are two ways to send a POST request over a socket to the IDOL Content component:

NOTE:

You can use these methods for other actions that require a POST request method, such as DREREPLACE, but you must modify the script.

Use the cURL Command-Line Tool

Curl is an open source command-line tool for transferring files with URL syntax. If you have cURL installed on your computer, and a command prompt that allows you to use new lines, you can use a cURL request to send the action. For example:

curl "http://host:port/DREADDDATA?" -d "
#DREREFERENCE Test
#DREDBNAME Default
#DREENDDOC
#DREENDDATA
"

Alternatively, you can add the #DREENDDATA tag into the IDX or XML document, or gzipped IDX or XML file, after the data to index. The #DREENDDATA tag must be uncompressed. Then you can use a cURL command to send this document to the IDOL Content component.

For example:

curl --data-binary @filename "http://host:port/DREADDDATA?"

where filename is the name of the IDX, XML, or gzipped IDX or XML file to index.

For information on cURL, refer to http://curl.haxx.se/.

Use a Script

Another method of sending a POST request is to use a script to open a socket and send the data. The following is an example script in the Perl programming language that sends a DREADDDATA index action to a specified port.

Example Perl Script

# Performs a /DREADDDATA index action
use IO::Socket;

if (@ARGV<3) 
{
   print "Usage: doDreAddData.pl <hostname> <indexport> <filename> [parameters]\n";
   exit;
}

my $host = $ARGV[0];
my $port = $ARGV[1];
my $filename = $ARGV[2];
my $params = $ARGV[3];
my $footer = "\r\n#DREENDDATA\r\n\r\n";
my $iaddr = inet_aton($host) or die "$!";
my $paddr = sockaddr_in($port,$iaddr);
my $proto = getprotobyname('tcp');

socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
connect(SOCK, $paddr) or die "connect: $!";

my $filesize = -s $filename;
$filesize += length($footer);
open (FILE, $filename) or die "couldn't open file: $!";

print SOCK "POST /DREADDDATA?$params HTTP/1.1\r\n";
print SOCK "Connection: close\r\n";
print SOCK "Content-Length: $filesize\r\n\r\n";
while (<FILE>)
{
   print SOCK $_;
}
print SOCK $footer;

SOCK->autoflush(1);
		
while(<SOCK>){
   print $_;
}

close FILE;
close SOCK;

_HP_HTML5_bannerTitle.htm