arunredi
11th April 2008, 05:38
Hello,
I'm trying to do a HTTP Post of a multipart/form-data. The form code is as below:
================================================== ===
<html>
<pre>
<form method="POST" enctype="multipart/form-data" action="http://beta.abc.com/app/submit.jsp">
Username: <input type="text" name="user" value="arun">
SHA1 encrypted pass: <input type="text" name="pass" value="1a27452283b0b46720913760f056377eb0b6388c">
<input type="hidden" name="v" value="1.0">
<input type="hidden" name="command" value="add">
<input type="submit" name="submit" value="submit">
</form>
</pre>
</html>
================================================== ===
Here is my Qt Code:
http = new QHttp(this);
connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
connect(http, SIGNAL(readyRead(const QHttpResponseHeader&)),
this, SLOT(readyRead(const QHttpResponseHeader&)));
http->setHost("beta.abc.com");
// Data
QByteArray data;
data.append(QString(QString("user=arun")+QString("&pass=1a27452283b0b46720913760f056377eb0b6388c&v=1.0&command=add")).toUtf8());
QHttpRequestHeader header("POST", "/app/submit.jsp");
header.setValue("Host", "beta.abc.com");
header.setContentType("multipart/form-data, boundary=AaB03x");
header.setContentLength(data.length());
http->request(header, data);
=========================================
For some reason the server doesn't like it and returns me an invalid username/ password error. I'm suspecting that I'm doing something wrong in the way I'm posting the data but not sure where the problem is.
Any help would be greatly appreciated.
thanks,
I'm trying to do a HTTP Post of a multipart/form-data. The form code is as below:
================================================== ===
<html>
<pre>
<form method="POST" enctype="multipart/form-data" action="http://beta.abc.com/app/submit.jsp">
Username: <input type="text" name="user" value="arun">
SHA1 encrypted pass: <input type="text" name="pass" value="1a27452283b0b46720913760f056377eb0b6388c">
<input type="hidden" name="v" value="1.0">
<input type="hidden" name="command" value="add">
<input type="submit" name="submit" value="submit">
</form>
</pre>
</html>
================================================== ===
Here is my Qt Code:
http = new QHttp(this);
connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
connect(http, SIGNAL(readyRead(const QHttpResponseHeader&)),
this, SLOT(readyRead(const QHttpResponseHeader&)));
http->setHost("beta.abc.com");
// Data
QByteArray data;
data.append(QString(QString("user=arun")+QString("&pass=1a27452283b0b46720913760f056377eb0b6388c&v=1.0&command=add")).toUtf8());
QHttpRequestHeader header("POST", "/app/submit.jsp");
header.setValue("Host", "beta.abc.com");
header.setContentType("multipart/form-data, boundary=AaB03x");
header.setContentLength(data.length());
http->request(header, data);
=========================================
For some reason the server doesn't like it and returns me an invalid username/ password error. I'm suspecting that I'm doing something wrong in the way I'm posting the data but not sure where the problem is.
Any help would be greatly appreciated.
thanks,