cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLAUTH_ANY Hangs on CURLOPT_PUT

From: Casey O'Donnell <caseyodonnell_at_hotmail.com>
Date: Thu, 10 Jun 2004 09:14:43 -0500

I've been having good luck with LibCURL, but when trying to switch my
authentication from CURLAUTH_BASIC to CURLAUTH_ANY (to obviously increase
security), my PUT requests appear to complete, but do not actually place
data on the server...

The GET requests work fine, but PUT requests seem to be timing out.
However, if I change the same PUT code to use CURLAUTH_BASIC, it works just
fine.

Just curious if someone else has had a problem doing this. I'm PUT-ing to a
WebDAV server, so it is HTTP 1.1 compliant...

Thanks for any help.

Casey

Get Code:

CURLcode res = CURLE_OK;

wxString szFullURL = m_szBaseURL + szRemoteFile;

m_szResponseHeader = wxEmptyString;
m_szResponseBody = wxEmptyString;

curl_easy_setopt(m_pCURL, CURLOPT_URL, szFullURL);
curl_easy_setopt(m_pCURL, CURLOPT_HEADERFUNCTION, wxcurldav_header_func);
curl_easy_setopt(m_pCURL, CURLOPT_WRITEHEADER, &m_szResponseHeader);
curl_easy_setopt(m_pCURL, CURLOPT_UPLOAD, FALSE);
curl_easy_setopt(m_pCURL, CURLOPT_HTTPGET, TRUE);
curl_easy_setopt(m_pCURL, CURLOPT_WRITEFUNCTION, wxcurldav_mem_write);
curl_easy_setopt(m_pCURL, CURLOPT_WRITEDATA, (void*)&data);
curl_easy_setopt(m_pCURL, CURLOPT_ERRORBUFFER, m_szErrorBuffer);

if(!m_szUsername.IsEmpty() || !m_szPassword.IsEmpty())
{
        m_szUserPass = m_szUsername + ":" + m_szPassword;

        curl_easy_setopt(m_pCURL, CURLOPT_USERPWD, m_szUserPass);
        curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
}

if(m_pParent && m_pDnloadGauge)
{
        curl_easy_setopt(m_pCURL, CURLOPT_NOPROGRESS, FALSE);
        curl_easy_setopt(m_pCURL, CURLOPT_PROGRESSFUNCTION,
wxcurldav_dl_progress_func);
        curl_easy_setopt(m_pCURL, CURLOPT_PROGRESSDATA, m_pDnloadGauge);

        m_pDnloadGauge->SetValue(0);
}

Put Code:

res = curl_easy_perform(m_pCURL);

curl_easy_getinfo(m_pCURL, CURLINFO_RESPONSE_CODE, &m_iResponseCode);

CURLcode res = CURLE_OK;

wxString szFullURL = m_szBaseURL + szRemoteFile;

m_szResponseHeader = wxEmptyString;
m_szResponseBody = wxEmptyString;

curl_easy_setopt(m_pCURL, CURLOPT_URL, szFullURL);
curl_easy_setopt(m_pCURL, CURLOPT_HEADERFUNCTION, wxcurldav_header_func);
curl_easy_setopt(m_pCURL, CURLOPT_WRITEHEADER, &m_szResponseHeader);
curl_easy_setopt(m_pCURL, CURLOPT_UPLOAD, TRUE);
curl_easy_setopt(m_pCURL, CURLOPT_PUT, TRUE);
curl_easy_setopt(m_pCURL, CURLOPT_READFUNCTION, wxcurldav_mem_read);
curl_easy_setopt(m_pCURL, CURLOPT_READDATA, (void*)&data);
curl_easy_setopt(m_pCURL, CURLOPT_INFILESIZE_LARGE, iSize);
curl_easy_setopt(m_pCURL, CURLOPT_WRITEFUNCTION, wxcurldav_str_write);
curl_easy_setopt(m_pCURL, CURLOPT_WRITEDATA, (void*)&m_szResponseBody);
curl_easy_setopt(m_pCURL, CURLOPT_ERRORBUFFER, m_szErrorBuffer);

if(!m_szUsername.IsEmpty() || !m_szPassword.IsEmpty())
{
        m_szUserPass = m_szUsername + ":" + m_szPassword;

        curl_easy_setopt(m_pCURL, CURLOPT_USERPWD, m_szUserPass);
        curl_easy_setopt(m_pCURL, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
}

if(m_pParent && m_pUploadGauge)
{
        curl_easy_setopt(m_pCURL, CURLOPT_NOPROGRESS, FALSE);
        curl_easy_setopt(m_pCURL, CURLOPT_PROGRESSFUNCTION,
wxcurldav_ul_progress_func);
        curl_easy_setopt(m_pCURL, CURLOPT_PROGRESSDATA, m_pUploadGauge);

        m_pUploadGauge->SetValue(0);
}

res = curl_easy_perform(m_pCURL);

curl_easy_getinfo(m_pCURL, CURLINFO_RESPONSE_CODE, &m_iResponseCode);

Header data and response code returned from PUT (CURLAUTH_ANY and
curl_perform call hangs (until time-out I suspect) and File is not updated):

Response Code: 100

HTTP/1.1 100 Continue

Header data and response code returned from PUT (CURLAUTH_BASIC and File is
updated):

Response Code: 204

HTTP/1.1 100 Continue

HTTP/1.1 204 No Content
Date: Thu, 10 Jun 2004 14:12:17 GMT
Server: Apache/1.3.14 (Unix) DAV/1.0.2
Content-Type: text/plain
X-Cache: MISS from idisk.mac.com
Connection: close

_________________________________________________________________
Looking to buy a house? Get informed with the Home Buying Guide from MSN
House & Home. http://coldwellbanker.msn.com/
Received on 2004-06-10