bool wxCurlHTTP::Put(wxInputStream& buffer, const wxString& szRemoteFile /*= wxEmptyString*/) { curl_off_t iSize = 0; if(m_pCURL && buffer.IsOk()) { SetCurlHandleToDefaults(szRemoteFile); iSize = buffer.GetSize(); if(iSize == (~(size_t)0)) // wxCurlHTTP does not know how to upload unknown length streams. return false; SetOpt(CURLOPT_UPLOAD, TRUE); SetOpt(CURLOPT_PUT, TRUE); SetStreamReadFunction(buffer); SetOpt(CURLOPT_INFILESIZE_LARGE, (curl_off_t)iSize); SetStringWriteFunction(m_szResponseBody); if(Perform()) { return IsResponseOk(); } } return false; }
bool wxCurlHTTP::Trace(const wxString& szRemoteFile /*= wxEmptyString*/) { if(m_pCURL) { SetCurlHandleToDefaults(szRemoteFile); m_arrHeaders.Add(wxT("Content-type: message/http")); SetHeaders(); SetOpt(CURLOPT_CUSTOMREQUEST, "TRACE"); SetStringWriteFunction(m_szResponseBody); if(Perform()) { ResetHeaders(); return IsResponseOk(); } ResetHeaders(); } return false; }
bool wxCurlFTP::Rename(const wxString& szRemoteLocName, const wxString& szRemoteFile /*= wxEmptyString*/) { if(m_pCURL) { SetCurlHandleToDefaults(szRemoteFile); wxString url(GetURL().c_str(), wxConvUTF8); m_szCurrFullPath = url.BeforeLast('/'); m_szCurrFullPath += wxS("/"); m_szCurrFilename = url.AfterLast('/'); if(m_szCurrFilename.IsEmpty()) return false; AppendPostQuote(wxS("RNFR ") + m_szCurrFilename, true); AppendPostQuote(wxS("RNTO ") + szRemoteLocName); SetCurlHandleQuoteOpts(); SetOpt(CURLOPT_NOBODY, TRUE); if(Perform()) { ResetAllQuoteLists(); return ((m_iResponseCode > 199) && (m_iResponseCode < 300)); } ResetAllQuoteLists(); } return false; }
bool wxCurlFTP::RmDir(const wxString& szRemoteLoc /*= wxEmptyString*/) { if(m_pCURL) { wxString str(szRemoteLoc); if(str.Last() != wxS('/')) str += wxS("/"); SetCurlHandleToDefaults(str); wxString url(GetURL().c_str(), wxConvUTF8); m_szCurrFullPath = url.Left(url.Len() - 1).BeforeLast(wxS('/')); m_szCurrFullPath += wxS("/"); m_szCurrFilename = url.Left(url.Len() - 1).AfterLast(wxS('/')); if(m_szCurrFilename.IsEmpty()) return false; AppendPostQuote(wxS("RMD ") + m_szCurrFilename, true); SetCurlHandleQuoteOpts(); SetOpt(CURLOPT_NOBODY, TRUE); if(Perform()) { ResetAllQuoteLists(); return ((m_iResponseCode > 199) && (m_iResponseCode < 300)); } ResetAllQuoteLists(); } return false; }
bool wxCurlFTP::Put(wxInputStream& buffer, const wxString& szRemoteFile /*= wxEmptyString*/) { curl_off_t iSize = 0; if(m_pCURL && buffer.IsOk()) { SetCurlHandleToDefaults(szRemoteFile); iSize = buffer.GetSize(); if(iSize == (~(ssize_t)0)) return false; SetOpt(CURLOPT_UPLOAD, TRUE); SetStreamReadFunction(buffer); SetOpt(CURLOPT_INFILESIZE_LARGE, iSize); if(Perform()) { return ((m_iResponseCode > 199) && (m_iResponseCode < 300)); } } return false; }
bool wxCurlFTP::Get(wxOutputStream& buffer, const wxString& szRemoteFile /*= wxEmptyString*/) { if(m_pCURL && buffer.IsOk()) { SetCurlHandleToDefaults(szRemoteFile); SetStreamWriteFunction(buffer); if(Perform()) { return ((m_iResponseCode > 199) && (m_iResponseCode < 299)); } } return false; }
bool wxCurlHTTP::Delete(const wxString& szRemoteLoc /*= wxEmptyString*/) { if(m_pCURL) { SetCurlHandleToDefaults(szRemoteLoc); SetOpt(CURLOPT_CUSTOMREQUEST, "DELETE"); SetStringWriteFunction(m_szResponseBody); if(Perform()) { return IsResponseOk(); } } return false; }
bool wxCurlHTTP::Get(wxOutputStream& buffer, const wxString& szRemoteFile /*=wxEmptyString*/) { if(m_pCURL && buffer.IsOk()) { SetCurlHandleToDefaults(szRemoteFile); SetOpt(CURLOPT_HTTPGET, TRUE); SetStreamWriteFunction(buffer); if(Perform()) { return IsResponseOk(); } } return false; }
bool wxCurlHTTP::Head(const wxString& szRemoteFile /*= wxEmptyString*/) { if(m_pCURL) { SetCurlHandleToDefaults(szRemoteFile); SetOpt(CURLOPT_HTTPGET, TRUE); SetOpt(CURLOPT_NOBODY, TRUE); if(Perform()) { return IsResponseOk(); } } return false; }
bool wxCurlFTP::Nlst(const wxString& szRemoteLoc /*= wxEmptyString*/) { if(m_pCURL) { SetCurlHandleToDefaults(szRemoteLoc); SetOpt(CURLOPT_CUSTOMREQUEST, "NLST"); SetStringWriteFunction(m_szResponseBody); if(Perform()) { return ((m_iResponseCode > 199) && (m_iResponseCode < 300)); } } return false; }
bool wxCurlFTP::Info(const wxString& szRemoteLoc /*= wxEmptyString*/) { if(m_pCURL) { SetCurlHandleToDefaults(szRemoteLoc); SetOpt(CURLOPT_HEADER, TRUE); SetOpt(CURLOPT_NOBODY, TRUE); SetStringWriteFunction(m_szResponseBody); if(Perform()) { return ((m_iResponseCode > 199) && (m_iResponseCode < 299)); } } return false; }
bool wxCurlHTTP::Post(const wxString& szRemoteFile /*= wxEmptyString*/) { if(m_pCURL && m_pPostHead && m_pPostTail) { SetCurlHandleToDefaults(szRemoteFile); SetOpt(CURLOPT_POST, TRUE); SetOpt(CURLOPT_HTTPPOST, m_pPostHead); SetStringWriteFunction(m_szResponseBody); if(Perform()) { return IsResponseOk(); } } return false; }
bool wxCurlFTP::MkDir(const wxString& szRemoteLoc /*= wxEmptyString*/) { if(m_pCURL) { wxString str(szRemoteLoc); if(str.Last() != '/') str += wxS("/"); SetCurlHandleToDefaults(str); SetOpt(CURLOPT_FTP_CREATE_MISSING_DIRS, TRUE); SetOpt(CURLOPT_NOBODY, TRUE); if(Perform()) { return ((m_iResponseCode > 199) && (m_iResponseCode < 300)); } } return false; }