[Qt-interest] Request to URL including percent

Anthony Serdyukov uksus70 at gmail.com
Wed Dec 17 05:31:12 CET 2008


Use QUrl::fromEncoded method. Not sure the method name is correct, see docs.

2008/12/17, KIMURA, Hidetaka <kimura at jig.jp>:
> Hello,
>
> I am using the network component of Qt.
> When I try to access a url that has a percent, it automatically encodes it
> into %25 and sends it to the remote host.
>
> Here is the sample code:
>
> #include <QApplication>
> #include <QDebug>
> #include <QNetworkAccessManager>
> #include <QNetworkRequest>
> #include <QNetworkReply>
>
> int main(int argc, char** argv)
> {
> 	QCoreApplication app(argc, argv);
> 	QNetworkAccessManager manager;
> 	QNetworkRequest req(QUrl("http://example.com/a%3Ab", QUrl::StrictMode));
> 	QNetworkReply* rep = manager.get(req);
> 	app.connect(rep, SIGNAL(finished()), SLOT(quit()));
>
> 	int rv = app.exec();
> 	qDebug() << "URL:" << rep->url();
> 	return rv;
> }
>
>
> This program generates an HTTP request like this:
> GET /a%253Ab HTTP1.1
>
> Can I avoid this behavior and get correct request /a%3Ab ?
>
> Thanks,
>
> -------
> KIMURA, Hide - kimura at jig.jp
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>


-- 
Regards,
Anthony



More information about the Qt-interest-old mailing list