-- Best Regards Reinhardt Behm, Dipl.-Phys R&D Director
mailto:rb...@becker.com.tw skype: reinhardt.behm Tel: +886 (0)3 471 0992 -16 Fax: +886 (0)3 471 6437 http://www.becker.com.tw Becker Electronics Taiwan Ltd. No.32, Lane 30,Long Yuan Rd., Long-Tan, Taoyuan 32544, Taiwan On Friday 20 May 2016 15:27:27 Eric Laffoon wrote: > Hi all, > > It's a little emberassing but I'm still using some Qt3 software. Kommander > is partially ported to Qt4 and I've been running my business with it since > 2007. I'm rebuilding my biz and hope to have more time in the future. I was > writing parser code a few years back but I'm really rusty now with C++. > > I need to be able to post data and I need to be able to send a custom header > which includes the user key as a header. It's very important and it looked > easy but I've been coding late at night several days with no joy. > > Can anyone recommend some Qt3 or Qt4 code that uses QHttp and associated > network classes to post with additional header data? I've managed to get > QHttp::post( const QString & path, const QByteArray & data, QIODevice * to = > 0 ) to work but it looks like I need to use the request function instead. > > This is the post function. > > > int Http::httpPost() > { > m_data = ""; > QString hdr; > QString str; > QByteArray arData; > QHttpResponseHeader header; > > for (QMapConstIterator<QString, QString> it = m_headers.begin(); it != > m_headers.end(); it++) > hdr += QString("%1 : %2\r\n").arg(it.key()).arg(it.data()); > hdr += ""; //"\r\n"; > > header = QHttpRequestHeader::QHttpRequestHeader(const hdr&); > > for (QMapConstIterator<QString, QString> it = m_values.begin(); it != > m_values.end(); it++) > str += QString("%1%2=%3").arg(it != m_values.begin() ? "&" : "") > .arg(it.key()).arg(it.data()); > > arData.duplicate(static_cast<const char *>(str), str.length()); > job->request(header&, arData&, 0); > > return 1; //not used > } > > QString Http::httpShowValues() > { > QString str; > for (QMapConstIterator<QString, QString> it = m_values.begin(); it != > m_values.end(); it++) > { > str += QString("%1\t%2%3") .arg(it.key()).arg(it.data()).arg(it != > m_values.end() ? "\n" : ""); > } > return str; > } > > > This is my current make error > > ../../src/http.cpp: In member function 'int Http::httpPost()': > ../../src/http.cpp:136:51: error: expected primary-expression before 'const' > header = QHttpRequestHeader::QHttpRequestHeader(const hdr&); > ^ > ../../src/http.cpp:136:61: error: cannot call constructor > 'QHttpRequestHeader::QHttpRequestHeader' directly [-fpermissive] > header = QHttpRequestHeader::QHttpRequestHeader(const hdr&); > ^ > ../../src/http.cpp:136:61: error: for a function-style cast, remove the > redundant '::QHttpRequestHeader' [-fpermissive] > > Yes, I know I have a constructor in there, but QHttpHeader::setValue is pure > virtual. I can't remember how to inherit that and use it in a QHttp object. > > I don't really have a week to brush up on C++. Just need to see how to > construct a request with headers and data. > Eric, I was in the same situation some time ago. The original program was done during Qt3.3 times and I had to port it to Qt5. Nearly all HTTP server stuff is gone. I ended up, doing it myself. It isn't that hard. If you give me until next week, I can extract the relevant parts (more or less 3 classes) and give it to you. -- Reinhardt _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest