QString HttpDaemon::generateHeader() { QString contentHeader( "HTTP/1.0 200 Ok\r\n" "Content-Type: text/html; charset=\"utf-8\"\r\n" "\r\n" ); return contentHeader; }
void CurlTransportAgent::send(const char *data, size_t len) { CURLcode code; m_replyLen = 0; m_message = data; m_messageSent = 0; m_messageLen = len; curl_slist_free_all(m_slist); m_slist = NULL; // Setting Expect explicitly prevents problems with certain // proxies: if curl is allowed to depend on Expect, then it will // send the POST header and wait for the servers reply that it is // allowed to continue. This will always be the case with a correctly // configured SyncML and because some proxies reject unknown Expect // requests, it is better not used. m_slist = curl_slist_append(m_slist, "Expect:"); std::string contentHeader("Content-Type: "); contentHeader += m_contentType; m_slist = curl_slist_append(m_slist, contentHeader.c_str()); m_status = ACTIVE; if (m_timeoutSeconds) { m_sendStartTime = Timespec::monotonic(); } m_aborting = false; if ((code = curl_easy_setopt(m_easyHandle, CURLOPT_PROGRESSDATA, static_cast<void *> (this)))|| (code = curl_easy_setopt(m_easyHandle, CURLOPT_HTTPHEADER, m_slist)) || (code = curl_easy_setopt(m_easyHandle, CURLOPT_POSTFIELDSIZE, len)) ){ m_status = CANCELED; checkCurl(code); } if ((code = curl_easy_perform(m_easyHandle))) { m_status = FAILED; checkCurl(code, false); } else { m_status = GOT_REPLY; } }