我的桌面應用程序是HTTP將數據發送到我的Apache服務器(與我的PHP腳本進行交互)。我張貼了大量的數據(大小爲800kb的文件的內容)。HTTP發送大字符串導致請求超時
當我發送HTTP POST請求超時與下面的Windows錯誤:
ERROR_INTERNET_TIMEOUT The request has timed out
但是,如果我送小文件,然後一切都很好,我的PHP腳本處理POST請求。這可能是什麼原因,我該如何解決這個問題?
我的網站是WordPress,我已經將我的php.ini
,php5.ini
和.user.ini
更改爲全部具有以下文本,但對於大型文件仍然失敗。
file_uploads = On
post_max_size = 128M
upload_max_filesize = 128M
編輯:使用phpinfo();
檢查後(的max_execution_time應當對端部的S(爲秒):
- 的max_execution_time 10
- memory_limit的128M
- 的post_max_size 128M
- upload_max_filesize 128M
- 個max_input_nesting_level 64
- max_input_time設置10個
- max_input_vars 1000
C++代碼:
TCHAR hdrs[] = _T("Content-Type: application/x-www-form-urlencoded");
LPSTR accept[2] = { "*/*", NULL };
HINTERNET hConnect = NULL, hSession = NULL, hRequest = NULL;
DWORD len = postData.length() * 2;
tstring formattedPostData(len, ' ');
InternetCanonicalizeUrl(postData.c_str(), &formattedPostData[0], &len, ICU_BROWSER_MODE);
std::replace(formattedPostData.begin(), formattedPostData.end(), '=', '~');
tstring authData = _T("usage=") + formattedPostData + _T("&auth=") + authToken;
hSession = InternetOpen(_T("uploader"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (!hSession) {
output(_T("InternetOpen failed: %s\n"), getLastErrorAsString().c_str());
res = S_UNDEFINED_ERROR.state;
goto Cleanup;
}
hConnect = InternetConnect(hSession, domain.c_str(),
INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);
if (!hConnect) {
output(_T("InternetConnect failed: %s\n"), getLastErrorAsString().c_str());
res = S_UNDEFINED_ERROR.state;
goto Cleanup;
}
hRequest = HttpOpenRequest(hConnect, _T("POST"),
domainScript.c_str(), NULL, NULL, (LPCWSTR*)&accept, INTERNET_FLAG_NO_CACHE_WRITE, 1);
if (!hRequest) {
output(_T("HttpOpenRequest failed: %s\n"), getLastErrorAsString().c_str());
res = S_UNDEFINED_ERROR.state;
goto Cleanup;
}
// Error occurs here
output(_T("Post: %s\n"), authData.c_str());
if (!HttpSendRequest(hRequest, hdrs, -1, (LPVOID)authData.c_str(), authData.size() * sizeof(TCHAR))) {
// Error is 12002: timeout
output(_T("HttpSendRequest failed: %d.\n"), GetLastError());
res = S_UNDEFINED_ERROR.state;
char responseText[1024];
DWORD responseTextSize = sizeof(responseText);
output(_T("Res: %d\n"), HttpQueryInfo(hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, &responseText, &responseTextSize, NULL));
output(_T("Response: %s\n"), responseText);
goto Cleanup;
}
檢查錯誤日誌,讓我知道。 –
也許這可以幫助你:[max_input_time](http://php.net/manual/de/info.configuration.php#ini.max-input-time) –
@SachinG。我檢查了錯誤日誌,今天沒有條目。 – Merl