MCPcopy Create free account
hub / github.com/OSGeo/gdal / Fill

Method Fill

port/cpl_http.cpp:781–875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

779 CPLHTTPPostFields(const CPLHTTPPostFields &) = delete;
780
781 CPLErr Fill(CURL *http_handle, CSLConstList papszOptions)
782 {
783 // Fill POST form if present
784 const char *pszFormFilePath =
785 CSLFetchNameValue(papszOptions, "FORM_FILE_PATH");
786 const char *pszParametersCount =
787 CSLFetchNameValue(papszOptions, "FORM_ITEM_COUNT");
788
789 if (pszFormFilePath != nullptr || pszParametersCount != nullptr)
790 {
791 mime = curl_mime_init(http_handle);
792 curl_mimepart *mimepart = curl_mime_addpart(mime);
793 if (pszFormFilePath != nullptr)
794 {
795 const char *pszFormFileName =
796 CSLFetchNameValue(papszOptions, "FORM_FILE_NAME");
797 const char *pszFilename = CPLGetFilename(pszFormFilePath);
798 if (pszFormFileName == nullptr)
799 {
800 pszFormFileName = pszFilename;
801 }
802
803 VSIStatBufL sStat;
804 if (VSIStatL(pszFormFilePath, &sStat) == 0)
805 {
806 VSILFILE *mime_fp = VSIFOpenL(pszFormFilePath, "rb");
807 if (mime_fp != nullptr)
808 {
809 curl_mime_name(mimepart, pszFormFileName);
810 CPL_IGNORE_RET_VAL(
811 curl_mime_filename(mimepart, pszFilename));
812 curl_mime_data_cb(
813 mimepart, sStat.st_size, CPLHTTPReadFunction,
814 CPLHTTPSeekFunction, CPLHTTPFreeFunction, mime_fp);
815 }
816 else
817 {
818 osErrMsg = CPLSPrintf("Failed to open file %s",
819 pszFormFilePath);
820 return CE_Failure;
821 }
822
823 CPLDebug("HTTP", "Send file: %s, COPYNAME: %s",
824 pszFormFilePath, pszFormFileName);
825 }
826 else
827 {
828 osErrMsg =
829 CPLSPrintf("File '%s' not found", pszFormFilePath);
830 return CE_Failure;
831 }
832 }
833
834 int nParametersCount = 0;
835 if (pszParametersCount != nullptr)
836 {
837 nParametersCount = atoi(pszParametersCount);
838 }

Callers 6

cog.pyFile · 0.45
doitFunction · 0.45
computeminmax.pyFile · 0.45
CPLHTTPFetchExFunction · 0.45

Calls 7

CSLFetchNameValueFunction · 0.85
CPLGetFilenameFunction · 0.85
VSIStatLFunction · 0.85
VSIFOpenLFunction · 0.85
CPLSPrintfFunction · 0.85
CPLDebugFunction · 0.85
CPL_IGNORE_RET_VALFunction · 0.70

Tested by

no test coverage detected