| Trolltech Home | Qt4-preview-feedback Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 1 | |
Hi, Did anyone manage to send an FTP request through an HTTP caching proxy ? Seems that sending an HTTP request works fine but it never works for FTP. Attached an example. I compiled it using: g++ -o p p.cc `pkg-config QtCore QtNetwork QtGui --cflags --libs` Using 4.4 RC1 Cheers, -- [ signature omitted ]
#include <qapplication.h>
#include <qnetworkproxy.h>
#include <qnetworkaccessmanager.h>
#include <qnetworkrequest.h>
#include <qnetworkreply.h>
#include <iostream>
class Req : public QObject {
Q_OBJECT
public:
Req() {
p.setHostName("172.16.42.42");
p.setPort(8080);
p.setType(QNetworkProxy::HttpCachingProxy);
m.setProxy(p);
QNetworkRequest rq1(QUrl("ftp://foolab.org"));
r1 = m.get(rq1);
QNetworkRequest rq2(QUrl("http://foolab.org"));
r2 = m.get(rq2);
QObject::connect(r1, SIGNAL(readyRead()), this, SLOT(r1Read()));
QObject::connect(r2, SIGNAL(readyRead()), this, SLOT(r2Read()));
}
private:
QNetworkAccessManager m;
QNetworkProxy p;
QNetworkReply *r1, *r2;
private Q_SLOTS:
void r1Read() {
qDebug() << "Request 1 " << r1->readAll();
}
void r2Read() {
qDebug() << "Request 2 " << r2->readAll();
}
};
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
Req r;
a.exec();
return 0;
}
// moc output:
/****************************************************************************
** Meta object code from reading C++ file 'p.cc'
**
** Created: Thu Apr 10 17:08:19 2008
** by: The Qt Meta Object Compiler version 59 (Qt 4.4.0-rc1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'p.cc' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 59
#error "This file was generated using the moc from 4.4.0-rc1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_Req[] = {
// content:
1, // revision
0, // classname
0, 0, // classinfo
2, 10, // methods
0, 0, // properties
0, 0, // enums/sets
// slots: signature, parameters, type, tag, flags
5, 4, 4, 4, 0x08,
14, 4, 4, 4, 0x08,
0 // eod
};
static const char qt_meta_stringdata_Req[] = {
"Req\0\0r1Read()\0r2Read()\0"
};
const QMetaObject Req::staticMetaObject = {
{ &QObject::staticMetaObject, qt_meta_stringdata_Req,
qt_meta_data_Req, 0 }
};
const QMetaObject *Req::metaObject() const
{
return &staticMetaObject;
}
void *Req::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_Req))
return static_cast<void*>(const_cast< Req*>(this));
return QObject::qt_metacast(_clname);
}
int Req::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QObject::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: r1Read(); break;
case 1: r2Read(); break;
}
_id -= 2;
}
return _id;
}
QT_END_MOC_NAMESPACE
Attachment:
Attachment:
signature.asc
Attachment:
signature.asc
Description: Digital signature
Message 2 in thread
On Thu, Apr 10, 2008 at 04:39:24PM +0200, Thiago Macieira wrote:
> On Thursday 10 April 2008 16:29:52 Mohammed Sameer wrote:
> > Did anyone manage to send an FTP request through an HTTP caching proxy ?
>
> This is not supported yet.
Thanks for info.
Any plans to support that in the future ?
Problem is, QtWebKit tries to grab files from FTP servers and there's no way to disable that.
I guess I need to implement a "hack" to prevent it from doing that.
Cheers,
--
[ signature omitted ]
Description: Digital signature