| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | 
|---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qhttp.h:1 --> | 
|---|
| 3 | <html> | 
|---|
| 4 | <head> | 
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | 
|---|
| 6 | <title>qhttp.h Include File</title> | 
|---|
| 7 | <style type="text/css"><!-- | 
|---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; } | 
|---|
| 9 | a:link { color: #004faf; text-decoration: none } | 
|---|
| 10 | a:visited { color: #672967; text-decoration: none } | 
|---|
| 11 | body { background: #ffffff; color: black; } | 
|---|
| 12 | --></style> | 
|---|
| 13 | </head> | 
|---|
| 14 | <body> | 
|---|
| 15 |  | 
|---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> | 
|---|
| 17 | <tr bgcolor="#E5E5E5"> | 
|---|
| 18 | <td valign=center> | 
|---|
| 19 | <a href="index.html"> | 
|---|
| 20 | <font color="#004faf">Home</font></a> | 
|---|
| 21 | | <a href="classes.html"> | 
|---|
| 22 | <font color="#004faf">All Classes</font></a> | 
|---|
| 23 | | <a href="mainclasses.html"> | 
|---|
| 24 | <font color="#004faf">Main Classes</font></a> | 
|---|
| 25 | | <a href="annotated.html"> | 
|---|
| 26 | <font color="#004faf">Annotated</font></a> | 
|---|
| 27 | | <a href="groups.html"> | 
|---|
| 28 | <font color="#004faf">Grouped Classes</font></a> | 
|---|
| 29 | | <a href="functions.html"> | 
|---|
| 30 | <font color="#004faf">Functions</font></a> | 
|---|
| 31 | </td> | 
|---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qhttp.h</h1> | 
|---|
| 33 |  | 
|---|
| 34 | <p>This is the verbatim text of the qhttp.h include file. It is provided only for illustration; the copyright remains with Trolltech. | 
|---|
| 35 | <hr> | 
|---|
| 36 | <pre> | 
|---|
| 37 | /**************************************************************************** | 
|---|
| 38 | ** $Id: qhttp-h.html 2051 2007-02-21 10:04:20Z chehrlic $ | 
|---|
| 39 | ** | 
|---|
| 40 | ** Definition of QHttp and related classes. | 
|---|
| 41 | ** | 
|---|
| 42 | ** Created : 970521 | 
|---|
| 43 | ** | 
|---|
| 44 | ** Copyright (C) 1997-2007 Trolltech ASA.  All rights reserved. | 
|---|
| 45 | ** | 
|---|
| 46 | ** This file is part of the network module of the Qt GUI Toolkit. | 
|---|
| 47 | ** | 
|---|
| 48 | ** This file may be distributed under the terms of the Q Public License | 
|---|
| 49 | ** as defined by Trolltech ASA of Norway and appearing in the file | 
|---|
| 50 | ** LICENSE.QPL included in the packaging of this file. | 
|---|
| 51 | ** | 
|---|
| 52 | ** This file may be distributed and/or modified under the terms of the | 
|---|
| 53 | ** GNU General Public License version 2 as published by the Free Software | 
|---|
| 54 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 55 | ** packaging of this file. | 
|---|
| 56 | ** | 
|---|
| 57 | ** Licensees holding valid Qt Enterprise Edition licenses may use this | 
|---|
| 58 | ** file in accordance with the Qt Commercial License Agreement provided | 
|---|
| 59 | ** with the Software. | 
|---|
| 60 | ** | 
|---|
| 61 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 
|---|
| 62 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 
|---|
| 63 | ** | 
|---|
| 64 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 
|---|
| 65 | **   information about Qt Commercial License Agreements. | 
|---|
| 66 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 
|---|
| 67 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 
|---|
| 68 | ** | 
|---|
| 69 | ** Contact info@trolltech.com if any conditions of this licensing are | 
|---|
| 70 | ** not clear to you. | 
|---|
| 71 | ** | 
|---|
| 72 | **********************************************************************/ | 
|---|
| 73 |  | 
|---|
| 74 | #ifndef QHTTP_H | 
|---|
| 75 | #define QHTTP_H | 
|---|
| 76 |  | 
|---|
| 77 | #ifndef QT_H | 
|---|
| 78 | #include "qobject.h" | 
|---|
| 79 | #include "qnetworkprotocol.h" | 
|---|
| 80 | #include "qstringlist.h" | 
|---|
| 81 | #endif // QT_H | 
|---|
| 82 |  | 
|---|
| 83 | #if !defined( QT_MODULE_NETWORK ) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_NETWORK ) | 
|---|
| 84 | #define QM_EXPORT_HTTP | 
|---|
| 85 | #define QM_TEMPLATE_EXTERN_HTTP | 
|---|
| 86 | #else | 
|---|
| 87 | #define QM_EXPORT_HTTP Q_EXPORT | 
|---|
| 88 | #define QM_TEMPLATE_EXTERN_HTTP Q_TEMPLATE_EXTERN | 
|---|
| 89 | #endif | 
|---|
| 90 |  | 
|---|
| 91 | #ifndef QT_NO_NETWORKPROTOCOL_HTTP | 
|---|
| 92 |  | 
|---|
| 93 | class QSocket; | 
|---|
| 94 | class QTimerEvent; | 
|---|
| 95 | class QTextStream; | 
|---|
| 96 | class QIODevice; | 
|---|
| 97 |  | 
|---|
| 98 | class QHttpPrivate; | 
|---|
| 99 | class QHttpRequest; | 
|---|
| 100 |  | 
|---|
| 101 | class QM_EXPORT_HTTP QHttpHeader | 
|---|
| 102 | { | 
|---|
| 103 | public: | 
|---|
| 104 | QHttpHeader(); | 
|---|
| 105 | QHttpHeader( const QHttpHeader& header ); | 
|---|
| 106 | QHttpHeader( const QString& str ); | 
|---|
| 107 | virtual ~QHttpHeader(); | 
|---|
| 108 |  | 
|---|
| 109 | QHttpHeader& operator=( const QHttpHeader& h ); | 
|---|
| 110 |  | 
|---|
| 111 | QString value( const QString& key ) const; | 
|---|
| 112 | void setValue( const QString& key, const QString& value ); | 
|---|
| 113 | void removeValue( const QString& key ); | 
|---|
| 114 |  | 
|---|
| 115 | QStringList keys() const; | 
|---|
| 116 | bool hasKey( const QString& key ) const; | 
|---|
| 117 |  | 
|---|
| 118 | bool hasContentLength() const; | 
|---|
| 119 | uint contentLength() const; | 
|---|
| 120 | void setContentLength( int len ); | 
|---|
| 121 |  | 
|---|
| 122 | bool hasContentType() const; | 
|---|
| 123 | QString contentType() const; | 
|---|
| 124 | void setContentType( const QString& type ); | 
|---|
| 125 |  | 
|---|
| 126 | virtual QString toString() const; | 
|---|
| 127 | bool isValid() const; | 
|---|
| 128 |  | 
|---|
| 129 | virtual int majorVersion() const = 0; | 
|---|
| 130 | virtual int minorVersion() const = 0; | 
|---|
| 131 |  | 
|---|
| 132 | protected: | 
|---|
| 133 | virtual bool parseLine( const QString& line, int number ); | 
|---|
| 134 | bool parse( const QString& str ); | 
|---|
| 135 | void setValid( bool ); | 
|---|
| 136 |  | 
|---|
| 137 | private: | 
|---|
| 138 | QMap<QString,QString> values; | 
|---|
| 139 | bool valid; | 
|---|
| 140 | }; | 
|---|
| 141 |  | 
|---|
| 142 | class QM_EXPORT_HTTP QHttpResponseHeader : public QHttpHeader | 
|---|
| 143 | { | 
|---|
| 144 | private: | 
|---|
| 145 | QHttpResponseHeader( int code, const QString& text = QString::null, int majorVer = 1, int minorVer = 1 ); | 
|---|
| 146 | QHttpResponseHeader( const QString& str ); | 
|---|
| 147 |  | 
|---|
| 148 | void setStatusLine( int code, const QString& text = QString::null, int majorVer = 1, int minorVer = 1 ); | 
|---|
| 149 |  | 
|---|
| 150 | public: | 
|---|
| 151 | QHttpResponseHeader(); | 
|---|
| 152 | QHttpResponseHeader( const QHttpResponseHeader& header ); | 
|---|
| 153 |  | 
|---|
| 154 | int statusCode() const; | 
|---|
| 155 | QString reasonPhrase() const; | 
|---|
| 156 |  | 
|---|
| 157 | int majorVersion() const; | 
|---|
| 158 | int minorVersion() const; | 
|---|
| 159 |  | 
|---|
| 160 | QString toString() const; | 
|---|
| 161 |  | 
|---|
| 162 | protected: | 
|---|
| 163 | bool parseLine( const QString& line, int number ); | 
|---|
| 164 |  | 
|---|
| 165 | private: | 
|---|
| 166 | int statCode; | 
|---|
| 167 | QString reasonPhr; | 
|---|
| 168 | int majVer; | 
|---|
| 169 | int minVer; | 
|---|
| 170 |  | 
|---|
| 171 | friend class QHttp; | 
|---|
| 172 | }; | 
|---|
| 173 |  | 
|---|
| 174 | class QM_EXPORT_HTTP QHttpRequestHeader : public QHttpHeader | 
|---|
| 175 | { | 
|---|
| 176 | public: | 
|---|
| 177 | QHttpRequestHeader(); | 
|---|
| 178 | QHttpRequestHeader( const QString& method, const QString& path, int majorVer = 1, int minorVer = 1 ); | 
|---|
| 179 | QHttpRequestHeader( const QHttpRequestHeader& header ); | 
|---|
| 180 | QHttpRequestHeader( const QString& str ); | 
|---|
| 181 |  | 
|---|
| 182 | void setRequest( const QString& method, const QString& path, int majorVer = 1, int minorVer = 1 ); | 
|---|
| 183 |  | 
|---|
| 184 | QString method() const; | 
|---|
| 185 | QString path() const; | 
|---|
| 186 |  | 
|---|
| 187 | int majorVersion() const; | 
|---|
| 188 | int minorVersion() const; | 
|---|
| 189 |  | 
|---|
| 190 | QString toString() const; | 
|---|
| 191 |  | 
|---|
| 192 | protected: | 
|---|
| 193 | bool parseLine( const QString& line, int number ); | 
|---|
| 194 |  | 
|---|
| 195 | private: | 
|---|
| 196 | QString m; | 
|---|
| 197 | QString p; | 
|---|
| 198 | int majVer; | 
|---|
| 199 | int minVer; | 
|---|
| 200 | }; | 
|---|
| 201 |  | 
|---|
| 202 | class QM_EXPORT_HTTP QHttp : public QNetworkProtocol | 
|---|
| 203 | { | 
|---|
| 204 | Q_OBJECT | 
|---|
| 205 |  | 
|---|
| 206 | public: | 
|---|
| 207 | QHttp(); | 
|---|
| 208 | QHttp( QObject* parent, const char* name = 0 ); // ### Qt 4.0: make parent=0 and get rid of the QHttp() constructor | 
|---|
| 209 | QHttp( const QString &hostname, Q_UINT16 port=80, QObject* parent=0, const char* name = 0 ); | 
|---|
| 210 | virtual ~QHttp(); | 
|---|
| 211 |  | 
|---|
| 212 | int supportedOperations() const; | 
|---|
| 213 |  | 
|---|
| 214 | enum State { Unconnected, HostLookup, Connecting, Sending, Reading, Connected, Closing }; | 
|---|
| 215 | enum Error { | 
|---|
| 216 | NoError, | 
|---|
| 217 | UnknownError, | 
|---|
| 218 | HostNotFound, | 
|---|
| 219 | ConnectionRefused, | 
|---|
| 220 | UnexpectedClose, | 
|---|
| 221 | InvalidResponseHeader, | 
|---|
| 222 | WrongContentLength, | 
|---|
| 223 | Aborted | 
|---|
| 224 | }; | 
|---|
| 225 |  | 
|---|
| 226 | int setHost(const QString &hostname, Q_UINT16 port=80 ); | 
|---|
| 227 |  | 
|---|
| 228 | int get( const QString& path, QIODevice* to=0 ); | 
|---|
| 229 | int post( const QString& path, QIODevice* data, QIODevice* to=0  ); | 
|---|
| 230 | int post( const QString& path, const QByteArray& data, QIODevice* to=0 ); | 
|---|
| 231 | int head( const QString& path ); | 
|---|
| 232 | int request( const QHttpRequestHeader &header, QIODevice *device=0, QIODevice *to=0 ); | 
|---|
| 233 | int request( const QHttpRequestHeader &header, const QByteArray &data, QIODevice *to=0 ); | 
|---|
| 234 |  | 
|---|
| 235 | int closeConnection(); | 
|---|
| 236 |  | 
|---|
| 237 | Q_ULONG bytesAvailable() const; | 
|---|
| 238 | Q_LONG readBlock( char *data, Q_ULONG maxlen ); | 
|---|
| 239 | QByteArray readAll(); | 
|---|
| 240 |  | 
|---|
| 241 | int currentId() const; | 
|---|
| 242 | QIODevice* currentSourceDevice() const; | 
|---|
| 243 | QIODevice* currentDestinationDevice() const; | 
|---|
| 244 | QHttpRequestHeader currentRequest() const; | 
|---|
| 245 | bool hasPendingRequests() const; | 
|---|
| 246 | void clearPendingRequests(); | 
|---|
| 247 |  | 
|---|
| 248 | State state() const; | 
|---|
| 249 |  | 
|---|
| 250 | Error error() const; | 
|---|
| 251 | QString errorString() const; | 
|---|
| 252 |  | 
|---|
| 253 | public slots: | 
|---|
| 254 | void abort(); | 
|---|
| 255 |  | 
|---|
| 256 | signals: | 
|---|
| 257 | void stateChanged( int ); | 
|---|
| 258 | void responseHeaderReceived( const QHttpResponseHeader& resp ); | 
|---|
| 259 | void readyRead( const QHttpResponseHeader& resp ); | 
|---|
| 260 | void dataSendProgress( int, int ); | 
|---|
| 261 | void dataReadProgress( int, int ); | 
|---|
| 262 |  | 
|---|
| 263 | void requestStarted( int ); | 
|---|
| 264 | void requestFinished( int, bool ); | 
|---|
| 265 | void done( bool ); | 
|---|
| 266 |  | 
|---|
| 267 | protected: | 
|---|
| 268 | void operationGet( QNetworkOperation *op ); | 
|---|
| 269 | void operationPut( QNetworkOperation *op ); | 
|---|
| 270 |  | 
|---|
| 271 | void timerEvent( QTimerEvent * ); | 
|---|
| 272 |  | 
|---|
| 273 | private slots: | 
|---|
| 274 | void clientReply( const QHttpResponseHeader &rep ); | 
|---|
| 275 | void clientDone( bool ); | 
|---|
| 276 | void clientStateChanged( int ); | 
|---|
| 277 |  | 
|---|
| 278 | void startNextRequest(); | 
|---|
| 279 | void slotReadyRead(); | 
|---|
| 280 | void slotConnected(); | 
|---|
| 281 | void slotError( int ); | 
|---|
| 282 | void slotClosed(); | 
|---|
| 283 | void slotBytesWritten( int ); | 
|---|
| 284 |  | 
|---|
| 285 | private: | 
|---|
| 286 | QHttpPrivate *d; | 
|---|
| 287 | void *unused; // ### Qt 4.0: remove this (in for binary compatibility) | 
|---|
| 288 | int bytesRead; | 
|---|
| 289 |  | 
|---|
| 290 | int addRequest( QHttpRequest * ); | 
|---|
| 291 | void sendRequest(); | 
|---|
| 292 | void finishedWithSuccess(); | 
|---|
| 293 | void finishedWithError( const QString& detail, int errorCode ); | 
|---|
| 294 |  | 
|---|
| 295 | void killIdleTimer(); | 
|---|
| 296 |  | 
|---|
| 297 | void init(); | 
|---|
| 298 | void setState( int ); | 
|---|
| 299 | void close(); | 
|---|
| 300 |  | 
|---|
| 301 | friend class QHttpNormalRequest; | 
|---|
| 302 | friend class QHttpSetHostRequest; | 
|---|
| 303 | friend class QHttpCloseRequest; | 
|---|
| 304 | friend class QHttpPGHRequest; | 
|---|
| 305 | }; | 
|---|
| 306 |  | 
|---|
| 307 | #define Q_DEFINED_QHTTP | 
|---|
| 308 | #include "qwinexport.h" | 
|---|
| 309 | #endif | 
|---|
| 310 | #endif | 
|---|
| 311 | </pre> | 
|---|
| 312 | <!-- eof --> | 
|---|
| 313 | <p><address><hr><div align=center> | 
|---|
| 314 | <table width=100% cellspacing=0 border=0><tr> | 
|---|
| 315 | <td>Copyright © 2007 | 
|---|
| 316 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> | 
|---|
| 317 | <td align=right><div align=right>Qt 3.3.8</div> | 
|---|
| 318 | </table></div></address></body> | 
|---|
| 319 | </html> | 
|---|