How to make a HTTP request in QTJambi
How I can make a HTTP request in QT jambi.
Code:
System.out.println(qURL.encodedHost());
header.setValue("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows 98)");
header.setValue("Pragma", "no-cache");
header.setValue("Host","miniorb.in" );
qHttp.setHost("minirob.in");
//qHttp.currentRequest();
qHttp.request(header);
I tried to connect with the page in this way. but when I am trying to read it, it is giving me blank output. help me how i can fix it.
Thanks In advance !!!
Re: How to make a HTTP request in QTJambi
You must connect void QHttp::requestFinished ( int id, bool error ) or QHttp::done ( bool error ) to some of your slots and then use readAll().
Re: How to make a HTTP request in QTJambi
can you explain me what is slot ... i read this thing from tutorial .. but i am not very clear how to connect with slot ..
Added after 54 minutes:
I tried to add slot in my code .. but it is still not working .. please point out my mistake in my code ...
Code:
package com.trolltech.qt.webkit;
import sun.awt.RequestFocusController;
import sun.security.pkcs.ParsingException;
import com.trolltech.qt.QtEnumerator;
import com.trolltech.qt.QSignalEmitter.Signal1;
import com.
trolltech.
qt.
core.
QObject;
import com.
trolltech.
qt.
core.
QUrl;
import com.
trolltech.
qt.
core.
QUrl.
ParsingMode;
import com.
trolltech.
qt.
network.
QHttp;
import com.trolltech.qt.network.QNetworkAccessManager;
import com.trolltech.qt.network.QNetworkReply;
import com.trolltech.qt.network.QNetworkRequest;
public class test {
private int httpGetId;
private boolean httpRequestAborted;
public test(){
String url = "http://www.msn.com/st?=1";
System.out.println(qURL.encodedHost());
header.setValue("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows 98)");
header.setValue("Pragma", "no-cache");
header.setValue("Host","miniorb.in" );
qHttp.setHost("minirob.in");
qHttp.request(header);
httpGetId = qHttp.get(qURL.path());
qHttp.requestFinished.connect(this, "httpRequestFinished(int,boolean)");
qHttp.responseHeaderReceived.connect(this,"readResponseHeader(QHttpResponseHeader)");
System.out.println("xyz : " + xyz.size());
System.out.println("print 1: " + qHttp.request(header));
String str = "Divanshu On work";
System.out.println("inside the finsihed()" + str);
}
private void httpRequestFinished(int requestId, boolean error)
{
System.out.println("httpRequestFinished");
if (requestId != httpGetId){
System.out.println("Error");
return;
}
}
{
if (responseHeader.statusCode() != 200) {
httpRequestAborted = true;
qHttp.abort();
}
}
public static void main(String args[]){
test window = new test();
}
}
Thanks in advance !!!