private void OnDebug(LibCurl.CURLINFOTYPE infoType, String msg, Object extraData) { if ((infoType == LibCurl.CURLINFOTYPE.CURLINFO_DATA_IN)) _htmlDataIn += msg; if ((infoType == LibCurl.CURLINFOTYPE.CURLINFO_HEADER_IN)) { Match httpCode = rxFindHttpCode.Match(msg);//get hettp code if (httpCode.Groups.Count > 1) HttpConnectCode = Convert.ToInt32(httpCode.Groups[1].Value); HtmlHeaderIn += msg; } if ((infoType == LibCurl.CURLINFOTYPE.CURLINFO_TEXT)) { HtmlText += msg; if (_verbose) sendLogEvent(msg, "Curl", Enums.MessageType.Info); } if ((infoType == LibCurl.CURLINFOTYPE.CURLINFO_END)) { EndText += msg; if (_verbose) sendLogEvent(msg, "Curl", Enums.MessageType.Info); } }
private bool AddFormFile(LibCurl.MultiPartForm mf, string fileName, Enums.HTMLField field) { return AddFormFile(mf, fileName, StringEnum.StrVal(field)); }
/// <summary> /// add information to upload a file, also perform check of file size and file existing /// </summary> private bool AddFormFile(LibCurl.MultiPartForm mf, string fileName, string field) { if (fileName != "") { if (!DrutNETBase.FileExists(fileName)) { sendLogEvent("Can't find file : " + fileName + "\n", "Curl", Enums.MessageType.Error); return false; } else if ((new FileInfo(fileName).Length / 1024) > Enums.MAXFILESIZEKB) { sendLogEvent(fileName + " size is bigger than limit (" + (Enums.MAXFILESIZEKB / 1024).ToString() + "MB)" + "\n", "Curl", Enums.MessageType.Error); return false; } else { LibCurl.CURLFORMcode res = mf.AddSection(LibCurl.CURLformoption.CURLFORM_COPYNAME, field, LibCurl.CURLformoption.CURLFORM_FILE, fileName, LibCurl.CURLformoption.CURLFORM_END); if (res != LibCurl.CURLFORMcode.CURL_FORMADD_OK) { sendLogEvent("Can't add Curl file: " + res.ToString() + "\n", "Curl", Enums.MessageType.Error); return false; } else return true; } } return false; }
private LibCurl.CURLFORMcode AddFormField(LibCurl.MultiPartForm mf, object fieldName, object Value) { LibCurl.CURLFORMcode res = mf.AddSection(LibCurl.CURLformoption.CURLFORM_COPYNAME, fieldName, LibCurl.CURLformoption.CURLFORM_COPYCONTENTS, Value, LibCurl.CURLformoption.CURLFORM_END); if (res != LibCurl.CURLFORMcode.CURL_FORMADD_OK) sendLogEvent("Can't add Curl field: " + res.ToString() + "\n", "Curl", Enums.MessageType.Error); return res; }