0
我正在編寫一個Python HTTPS服務器,其中客戶端將文件(1到10 MB之間的二進制文件)上載到其中。我使用HTTPServer與定製BaseHTTPRequestHandler。該請求由該下面的代碼處理:函數cgi.FieldStorage凍結Python HTTPS服務器
ctype, pdict = cgi.parse_header(self.headers.getheader('content-type'))
if ctype == "multipart/form-data":
fs = cgi.FieldStorage(fp = self.rfile, \
headers = self.headers, \
environ = {'REQUEST_METHOD':'POST'})
客戶端被用C++編寫與的libcurl。該請求是通過此下面的代碼發送:
std::string url = getURLServer("senddata");
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
std::string szPostFields = "id=" + std::to_string(ID);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, szPostFields.c_str());
struct curl_httppost *post = NULL;
struct curl_httppost *last = NULL;
curl_formadd(&post, &last,
CURLFORM_COPYNAME, "logfile",
CURLFORM_FILECONTENT, ".\\log.bin",
CURLFORM_END);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
res = curl_easy_perform(curl);
的問題是在cgi.FieldStorage(...)
服務器死機。如果我不上傳文件,它不會凍結。