[Cmake-commits] [cmake-commits] zach.mullen committed cmCTest.cxx 1.388 1.389 cmCTest.h 1.132 1.133

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Dec 30 11:10:45 EST 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv9848

Modified Files:
	cmCTest.cxx cmCTest.h 
Log Message:
Enhanced CTest HTTP Request API to support PUT file uploads.


Index: cmCTest.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCTest.h,v
retrieving revision 1.132
retrieving revision 1.133
diff -C 2 -d -r1.132 -r1.133
*** cmCTest.h	29 Dec 2009 19:38:31 -0000	1.132
--- cmCTest.h	30 Dec 2009 16:10:42 -0000	1.133
***************
*** 84,88 ****
    enum HTTPMethod {
      HTTP_GET,
!     HTTP_POST
    };
  
--- 84,89 ----
    enum HTTPMethod {
      HTTP_GET,
!     HTTP_POST,
!     HTTP_PUT
    };
  
***************
*** 92,96 ****
    static int HTTPRequest(std::string url, HTTPMethod method,
                            std::string& response,
!                           std::string fields = "", int timeout = 10);
  #endif
  
--- 93,98 ----
    static int HTTPRequest(std::string url, HTTPMethod method,
                            std::string& response,
!                           std::string fields = "", 
!                           std::string putFile = "", int timeout = 0);
  #endif
  

Index: cmCTest.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCTest.cxx,v
retrieving revision 1.388
retrieving revision 1.389
diff -C 2 -d -r1.388 -r1.389
*** cmCTest.cxx	29 Dec 2009 20:48:14 -0000	1.388
--- cmCTest.cxx	30 Dec 2009 16:10:41 -0000	1.389
***************
*** 173,192 ****
  int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
                                         std::string& response,
!                                        std::string fields, int timeout)
  {
    CURL* curl;
    ::curl_global_init(CURL_GLOBAL_ALL);
    curl = ::curl_easy_init();
  
!   //set request options
!   if(method == cmCTest::HTTP_GET && fields.size())
!     {
!     url += "?" + fields;
!     }
!   else
      {
!     ::curl_easy_setopt(curl, CURLOPT_POST, 1);
!     ::curl_easy_setopt(curl, CURLOPT_POSTFIELDS, fields.c_str());
      }
    ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
--- 173,212 ----
  int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
                                         std::string& response,
!                                        std::string fields,
!                                        std::string putFile, int timeout)
  {
    CURL* curl;
+   FILE* file;
    ::curl_global_init(CURL_GLOBAL_ALL);
    curl = ::curl_easy_init();
  
!   //set request options based on method
!   switch(method)
      {
!     case cmCTest::HTTP_POST:
!       ::curl_easy_setopt(curl, CURLOPT_POST, 1);
!       ::curl_easy_setopt(curl, CURLOPT_POSTFIELDS, fields.c_str());
!       break;
!     case cmCTest::HTTP_PUT:
!       if(!cmSystemTools::FileExists(putFile.c_str()))
!         {
!         response = "Error: File ";
!         response += putFile + " does not exist.\n";
!         return -1;
!         }
!       ::curl_easy_setopt(curl, CURLOPT_PUT, 1);
!       file = ::fopen(putFile.c_str(), "rb");
!       ::curl_easy_setopt(curl, CURLOPT_INFILE, file);
!       //fall through to append GET fields
!     case cmCTest::HTTP_GET:
!       if(fields.size())
!         {
!         url += "?" + fields;
!         }
!       break;
!     default:
!       break;
      }
+   
    ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);



More information about the Cmake-commits mailing list