我最好尝试从upload.com下载文件,但都是徒劳的。我尝试了所有可能的重定向方式,但都是徒劳的。它总是以错误Moved Permanently结束,如果你尝试重定向,它最终会下载网页。咦!
This is the cookie which i have to pass to QNetworkAccessManager:
S=gmail=gPwZoKGL8hgGA4ZHoej_Tg; S=gmail=xrWQCf29oq77myB3uSRKPg;
request.setUrl(url);
request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
cookieJar->setCookiesFromUrl(QNetworkCookie::parseCookies(cookie),url);
manager.setCookieJar(cookieJar);
reply=manager.get(request);
完成的信号调用以下插槽
int statusCode=0;
statusCode=reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if(statusCode>300)
{
if(statusCode==307||reply->rawHeaderList().contains("Location"))
{
url=reply->header(QNetworkRequest::LocationHeader).toString();
request.setUrl(url);
request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
cookieJar->setCookiesFromUrl(QNetworkCookie::parseCookies(cookie),url);
manager.setCookieJar(cookieJar);
reply=manager.get(request);
return;
}
下载失败,因为它下载网页而不是文件。网址和cookie由flashgot addon,firefox提供。