2018-07-30 Fred Gleason <fredg@paravelsystems.com>

* Modified 'RDRehash' to use multipart-mime encoding.
This commit is contained in:
Fred Gleason
2018-07-30 10:27:00 -04:00
parent 210bc3dc16
commit a466c39bc0
2 changed files with 22 additions and 8 deletions

View File

@@ -17265,3 +17265,5 @@
* Modified 'RDCopyAudio' to use multipart-mime encoding. * Modified 'RDCopyAudio' to use multipart-mime encoding.
2018-07-30 Fred Gleason <fredg@paravelsystems.com> 2018-07-30 Fred Gleason <fredg@paravelsystems.com>
* Modified 'RDPeakExport' to use multipart-mime encoding. * Modified 'RDPeakExport' to use multipart-mime encoding.
2018-07-30 Fred Gleason <fredg@paravelsystems.com>
* Modified 'RDRehash' to use multipart-mime encoding.

View File

@@ -2,7 +2,7 @@
// //
// Generate a SHA-1 hash of an audio file and write it to the database. // Generate a SHA-1 hash of an audio file and write it to the database.
// //
// (C) Copyright 2017 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2017-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as // it under the terms of the GNU General Public License version 2 as
@@ -70,15 +70,28 @@ RDRehash::ErrorCode RDRehash::runRehash(const QString &username,
CURL *curl=NULL; CURL *curl=NULL;
char url[1024]; char url[1024];
CURLcode curl_err; CURLcode curl_err;
struct curl_httppost *first=NULL;
struct curl_httppost *last=NULL;
// //
// Generate POST Data // Generate POST Data
// //
QString post=QString().sprintf("COMMAND=%d&",RDXPORT_COMMAND_REHASH)+ curl_formadd(&first,&last,CURLFORM_PTRNAME,"COMMAND",
"LOGIN_NAME="+RDFormPost::urlEncode(username)+"&"+ CURLFORM_COPYCONTENTS,
"PASSWORD="+RDFormPost::urlEncode(password)+"&"+ (const char *)QString().sprintf("%u",RDXPORT_COMMAND_REHASH),
QString().sprintf("CART_NUMBER=%u&",conv_cart_number)+ CURLFORM_END);
QString().sprintf("CUT_NUMBER=%u",conv_cut_number); curl_formadd(&first,&last,CURLFORM_PTRNAME,"LOGIN_NAME",
CURLFORM_COPYCONTENTS,(const char *)username,CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"PASSWORD",
CURLFORM_COPYCONTENTS,(const char *)password,CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"CART_NUMBER",
CURLFORM_COPYCONTENTS,
(const char *)QString().sprintf("%u",conv_cart_number),
CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"CUT_NUMBER",
CURLFORM_COPYCONTENTS,
(const char *)QString().sprintf("%u",conv_cut_number),
CURLFORM_END);
if((curl=curl_easy_init())==NULL) { if((curl=curl_easy_init())==NULL) {
return RDRehash::ErrorInternal; return RDRehash::ErrorInternal;
} }
@@ -91,8 +104,7 @@ RDRehash::ErrorCode RDRehash::runRehash(const QString &username,
strncpy(url,conv_station->webServiceUrl(conv_config),1024); strncpy(url,conv_station->webServiceUrl(conv_config),1024);
curl_easy_setopt(curl,CURLOPT_URL,url); curl_easy_setopt(curl,CURLOPT_URL,url);
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,__RDRehashCallback); curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,__RDRehashCallback);
curl_easy_setopt(curl,CURLOPT_POST,1); curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
curl_easy_setopt(curl,CURLOPT_POSTFIELDS,(const char *)post);
curl_easy_setopt(curl,CURLOPT_USERAGENT, curl_easy_setopt(curl,CURLOPT_USERAGENT,
(const char *)conv_config->userAgent()); (const char *)conv_config->userAgent());
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT); curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);