Store Content in IDOL Server > Index Data > DREADDDATA: Index Data over a Socket > Send Data with a POST Method

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 IDOL server:
*
*
 
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, then 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 IDOL server.
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.
To run the script
*
PerlScript.pl HostName IndexPort Filename [Parameters]
where,
 
is the name of the file that you index into IDOL server using the DREADDDATA action. You can use an IDX, XML or gzipped IDX or XML file.
Example Perl Script
# Performs a /DREADDDATA index command
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;