@@ -127,10 +127,12 @@ RESTClient<ServerTraits>::SetOutputFile(FILE *outfile)
127127
128128template <typename ServerTraits>
129129void
130- RESTClient<ServerTraits>::SetupCookies(bool read_only )
130+ RESTClient<ServerTraits>::SetupCookies(bool receive_cookie_mode )
131131{
132- m_Traits.SetupCookies (
133- m_SharedData ? m_SharedData->GetShare () : nullptr , m_Curl, GetServerURL ().c_str (), read_only);
132+ m_Traits.SetupCookies (m_SharedData ? m_SharedData->GetShare () : nullptr ,
133+ m_Curl,
134+ GetServerURL ().c_str (),
135+ receive_cookie_mode);
134136}
135137
136138template <typename ServerTraits>
@@ -148,7 +150,7 @@ RESTClient<ServerTraits>::Authenticate(const char *token)
148150 curl_easy_setopt (m_Curl, CURLOPT_POSTFIELDS, post_buffer);
149151
150152 // Set up the cookie jar to receive cookies
151- SetupCookies (false );
153+ SetupCookies (true );
152154
153155 // Capture output
154156 m_Output.clear ();
@@ -300,6 +302,7 @@ RESTClient<ServerTraits>::PostVA(const char *rel_url, const char *post_string, s
300302 }
301303
302304 // Make request
305+ // std::cout << "curl request to: " << url << " with data " << post_filled << std::endl;
303306 CURLcode res = curl_easy_perform (m_Curl);
304307
305308 if (res != CURLE_OK)
@@ -718,7 +721,7 @@ DSSServerTraits::SetServerURL(const char *baseurl)
718721}
719722
720723void
721- DSSServerTraits::SetupCookies (void *share, void *handle, const char *url, bool read_only )
724+ DSSServerTraits::SetupCookies (void *share, void *handle, const char *url, bool receive_cookie_mode )
722725{
723726 // MD5 encode the server
724727 char hex_code[33 ];
@@ -730,10 +733,16 @@ DSSServerTraits::SetupCookies(void *share, void *handle, const char *url, bool r
730733 itksysMD5_Delete (md5);
731734
732735 string cookie_jar = GetDataDirectory () + " /cookie_" + hex_code + " .jar" ;
733- if (read_only )
734- curl_easy_setopt (handle, CURLOPT_COOKIEFILE, cookie_jar. c_str ());
735- else
736+ if (receive_cookie_mode )
737+ {
738+ curl_easy_setopt (handle, CURLOPT_COOKIEFILE, nullptr );
736739 curl_easy_setopt (handle, CURLOPT_COOKIEJAR, cookie_jar.c_str ());
740+ }
741+ else
742+ {
743+ curl_easy_setopt (handle, CURLOPT_COOKIEJAR, nullptr );
744+ curl_easy_setopt (handle, CURLOPT_COOKIEFILE, cookie_jar.c_str ());
745+ }
737746}
738747
739748string
@@ -787,11 +796,11 @@ DLSServerTraits::SetServerURL(const char *baseurl)
787796}
788797
789798void
790- DLSServerTraits::SetupCookies (void *share, void *handle, const char *url, bool read_only )
799+ DLSServerTraits::SetupCookies (void *share, void *handle, const char *url, bool receive_cookie_mode )
791800{
792801 if (share)
793802 {
794- if (read_only )
803+ if (receive_cookie_mode )
795804 curl_easy_setopt (handle, CURLOPT_COOKIEFILE, " " );
796805 else
797806 curl_easy_setopt (handle, CURLOPT_COOKIEJAR, " " );
0 commit comments