qnetworkaccessmanager

Uploading files using Qt QNetworkRequest

两盒软妹~` 提交于 2019-12-01 15:54:36
I've been having some issues trying to upload files to a server using QNetworkRequest. I've been using this link ( http://qt-project.org/forums/viewthread/11361 ) mostly as a template, but am still getting POST errors (203 to be specific). Here is what I have so far. void MainWindow::processFile(){ QByteArray postData; //Look below for buildUploadString() function postData = mReport->buildUploadString(); QUrl mResultsURL = QUrl("http://" + VariableManager::getInstance()->getServerIP() + "/uploadFile.php"); QNetworkAccessManager* mNetworkManager = new QNetworkAccessManager(this); QString bound=

File Upload Error With QNetworkAccessManager

北城余情 提交于 2019-12-01 03:23:35
问题 I am trying to upload a file to a server using QNetworkAccessManager in Qt 5.0 on CentOS 6.4. I have tried following a few examples online but none of them work. QFTP works just fine but is slow and now deprecated. My code for the upload is: void ftp::start(QString fileLocation) { QUrl url2("ftp://example.com"); url2.setUserName(ftpusername); url2.setPassword(ftppassword); data = new QFile(fileLocation, this); if (data->open(QIODevice::ReadOnly)) { nam = new QNetworkAccessManager(); reply =

QNetworkRequest and default SSL configuration

冷暖自知 提交于 2019-11-30 13:38:07
I'm using the following piece of code to make HTTPS requests with a server. QNetworkRequest request; //request.setSslConfiguration(QSslConfiguration::defaultConfiguration()); request.setUrl(QUrl("https://www.someurl.com/")); QNetworkReply *reply = manager->get(request); Everything seems to be working with my test server, but I would like to know if it is recommended to set the defaultConfiguration (uncomment second line) or does the network API automatically check all defaultConfigurations when using SSL? And if it checks, does it also do if I add one custom configuration? I mean, is it

QNetworkReply and 301 redirect

不羁的心 提交于 2019-11-30 08:35:53
问题 I have a webviewer and only want it to only be able to access our webapps, to achieve this I have placed a php header which I look for in my Qt App. This works fine but with one exception and that's with 301 permanent moved status codes. Modern browsers redirect you automatically but putting a "/" at the end of the http request. When a URL to our web app is entered it currently needs the trailing slash to be able to detect the headers but I want it to also get at that header even if they don

Sending an HTTP request using QNetworkAccessManager

蹲街弑〆低调 提交于 2019-11-29 17:57:17
I've got a problem trying to send a request using QNetworkAccessManager from a QObject derived class. Firstly in my constructor I do the following: QObject::connect( &mAccessManager, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( requestFinished( QNetworkReply* ) ) ); Then when I wish to send the request I do the following: QNetworkRequest checkLogin( QUrl( address ) ); checkLogin.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" ); mByteArray = QByteArray( "POST \"client\" : oxres" ); QNetworkReply* pReply = mAccessManager.post( checkLogin, mByteArray );

How do I save cookies with Qt?

六月ゝ 毕业季﹏ 提交于 2019-11-29 15:52:50
问题 I am trying to save cookies that are produced by my app to disk location such as C:\Users\Username\AppData\Local\MyCompany\MyApp . I have implemented a webview and have pretty much finished coding my simple browser the final thing to do is save cookies. I am can qDebug() the cookies I get from the webapp and they show the cookies are formed correctly but I am a)unsure where to go from there and b) not 100% sure on how to make a subclass of the cookiejar class? Below I create my cookiejar

Qt Download File - QNetworkAccessManager, not getting data

99封情书 提交于 2019-11-29 15:43:26
I'm trying to have my application download a file from a URL, typically an EXE or a Jar, not that this should change much though. I have this all running in a thread, but I don't think that will make a difference (if it does let me know). So Do_Download is my function that creates the manager, sets the URL and request, and performs get. I then try to connect the finished signal to the slot the will write the file. void DownloadManager::Do_Download() { QNetworkAccessManager *netManager = new QNetworkAccessManager(this); QUrl url(install_mirror); //istall_mirror is the URL provided by user

QNetworkReply and 301 redirect

风格不统一 提交于 2019-11-29 07:09:19
I have a webviewer and only want it to only be able to access our webapps, to achieve this I have placed a php header which I look for in my Qt App. This works fine but with one exception and that's with 301 permanent moved status codes. Modern browsers redirect you automatically but putting a "/" at the end of the http request. When a URL to our web app is entered it currently needs the trailing slash to be able to detect the headers but I want it to also get at that header even if they don't put a trailing slash. Here is my current method to retrieve the header: QNetworkAccessManager

QNetworkReply wait for finished

三世轮回 提交于 2019-11-29 01:49:34
I am using Qt 4.6.3 and the following not-working code QStringList userInfo; QNetworkRequest netRequest(QUrl("http://api.stackoverflow.com/1.1/users/587532")); QNetworkReply *netReply = netman->get(netRequest); // from here onwards not working netReply->waitForReadyRead(-1); if (netReply->isFinished()==true) {userInfo << do sth to reply;} return userInfo; as this function returns an empty QStringList, the app crashes. How to wait until the request has finished and then process the reply within one function You can use event loop: QEventLoop loop; connect(netReply, SIGNAL(finished()), &loop,

Basic authentication with Qt (QNetworkAccessManager)

£可爱£侵袭症+ 提交于 2019-11-28 23:41:34
I was trying to perform basic authentication for Twitter from my Qt app. I use QNetworkAccessManager. But I couldn't find any help on this. But I found a program called qsoapmanager which passes credentials in base64 through the header. Maybe I can do this with QNAM by setting header in QNetowrkRequest. But I failed to find a way. In qsoapman source, header is set like this: QHttpRequestHeader header; header.setValue( "Authorization", QString( "Basic " ).append( auth.data() ) ); Can I do just that with QNAM/QNReq or is there a better way? Lukáš Lalinský The recommended way is to connect to the