summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/qhttp.3qt
blob: dee48b68afa7a6f8c49b887dc3f41580a1b58fb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
'\" t
.TH QHttp 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QHttp \- Implementation of the HTTP protocol
.SH SYNOPSIS
\fC#include <qhttp.h>\fR
.PP
Inherits QNetworkProtocol.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQHttp\fR ()"
.br
.ti -1c
.BI "\fBQHttp\fR ( QObject * parent, const char * name = 0 )"
.br
.ti -1c
.BI "\fBQHttp\fR ( const QString & hostname, Q_UINT16 port = 80, QObject * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "virtual \fB~QHttp\fR ()"
.br
.ti -1c
.BI "enum \fBState\fR { Unconnected, HostLookup, Connecting, Sending, Reading, Connected, Closing }"
.br
.ti -1c
.BI "enum \fBError\fR { NoError, UnknownError, HostNotFound, ConnectionRefused, UnexpectedClose, InvalidResponseHeader, WrongContentLength, Aborted }"
.br
.ti -1c
.BI "int \fBsetHost\fR ( const QString & hostname, Q_UINT16 port = 80 )"
.br
.ti -1c
.BI "int \fBget\fR ( const QString & path, QIODevice * to = 0 )"
.br
.ti -1c
.BI "int \fBpost\fR ( const QString & path, QIODevice * data, QIODevice * to = 0 )"
.br
.ti -1c
.BI "int \fBpost\fR ( const QString & path, const QByteArray & data, QIODevice * to = 0 )"
.br
.ti -1c
.BI "int \fBhead\fR ( const QString & path )"
.br
.ti -1c
.BI "int \fBrequest\fR ( const QHttpRequestHeader & header, QIODevice * data = 0, QIODevice * to = 0 )"
.br
.ti -1c
.BI "int \fBrequest\fR ( const QHttpRequestHeader & header, const QByteArray & data, QIODevice * to = 0 )"
.br
.ti -1c
.BI "int \fBcloseConnection\fR ()"
.br
.ti -1c
.BI "Q_ULONG \fBbytesAvailable\fR () const"
.br
.ti -1c
.BI "Q_LONG \fBreadBlock\fR ( char * data, Q_ULONG maxlen )"
.br
.ti -1c
.BI "QByteArray \fBreadAll\fR ()"
.br
.ti -1c
.BI "int \fBcurrentId\fR () const"
.br
.ti -1c
.BI "QIODevice * \fBcurrentSourceDevice\fR () const"
.br
.ti -1c
.BI "QIODevice * \fBcurrentDestinationDevice\fR () const"
.br
.ti -1c
.BI "QHttpRequestHeader \fBcurrentRequest\fR () const"
.br
.ti -1c
.BI "bool \fBhasPendingRequests\fR () const"
.br
.ti -1c
.BI "void \fBclearPendingRequests\fR ()"
.br
.ti -1c
.BI "State \fBstate\fR () const"
.br
.ti -1c
.BI "Error \fBerror\fR () const"
.br
.ti -1c
.BI "QString \fBerrorString\fR () const"
.br
.in -1c
.SS "Public Slots"
.in +1c
.ti -1c
.BI "void \fBabort\fR ()"
.br
.in -1c
.SS "Signals"
.in +1c
.ti -1c
.BI "void \fBstateChanged\fR ( int state )"
.br
.ti -1c
.BI "void \fBresponseHeaderReceived\fR ( const QHttpResponseHeader & resp )"
.br
.ti -1c
.BI "void \fBreadyRead\fR ( const QHttpResponseHeader & resp )"
.br
.ti -1c
.BI "void \fBdataSendProgress\fR ( int done, int total )"
.br
.ti -1c
.BI "void \fBdataReadProgress\fR ( int done, int total )"
.br
.ti -1c
.BI "void \fBrequestStarted\fR ( int id )"
.br
.ti -1c
.BI "void \fBrequestFinished\fR ( int id, bool error )"
.br
.ti -1c
.BI "void \fBdone\fR ( bool error )"
.br
.in -1c
.SH DESCRIPTION
The QHttp class provides an implementation of the HTTP protocol.
.PP
This class provides two different interfaces: one is the QNetworkProtocol interface that allows you to use HTTP through the QUrlOperator abstraction. The other is a direct interface to HTTP that allows you to have more control over the requests and that allows you to access the response header fields.
.PP
Don't mix the two interfaces, since the behavior is not well-defined.
.PP
If you want to use QHttp with the QNetworkProtocol interface, you do not use it directly, but rather through a QUrlOperator, for example:
.PP
.nf
.br
    QUrlOperator op( "http://www.trolltech.com" );
.br
    op.get( "index.html" );
.br
.fi
.PP
This code will only work if the QHttp class is registered; to register the class, you must call qInitNetworkProtocols() before using a QUrlOperator with HTTP.
.PP
The QNetworkProtocol interface for HTTP only supports the operations operationGet() and operationPut(), i.e. QUrlOperator::get() and QUrlOperator::put(), if you use it with a QUrlOperator.
.PP
The rest of this descrption describes the direct interface to HTTP.
.PP
The class works asynchronously, so there are no blocking functions. If an operation cannot be executed immediately, the function will still return straight away and the operation will be scheduled for later execution. The results of scheduled operations are reported via signals. This approach depends on the event loop being in operation.
.PP
The operations that can be scheduled (they are called "requests" in the rest of the documentation) are the following: setHost(), get(), post(), head() and request().
.PP
All of these requests return a unique identifier that allows you to keep track of the request that is currently executed. When the execution of a request starts, the requestStarted() signal with the identifier is emitted and when the request is finished, the requestFinished() signal is emitted with the identifier and a bool that indicates if the request finished with an error.
.PP
To make an HTTP request you must set up suitable HTTP headers. The following example demonstrates, how to request the main HTML page from the Trolltech home page (i.e. the URL http://www.trolltech.com/index.html):
.PP
.nf
.br
    QHttpRequestHeader header( "GET", "/index.html" );
.br
    header.setValue( "Host", "www.trolltech.com" );
.br
    http->setHost( "www.trolltech.com" );
.br
    http->request( header );
.br
.fi
.PP
For the common HTTP requests \fCGET\fR, \fCPOST\fR and \fCHEAD\fR, QHttp provides the convenience functions get(), post() and head(). They already use a reasonable header and if you don't have to set special header fields, they are easier to use. The above example can also be written as:
.PP
.nf
.br
    http->setHost( "www.trolltech.com" ); // id == 1
.br
    http->get( "/index.html" );           // id == 2
.br
.fi
.PP
For this example the following sequence of signals is emitted (with small variations, depending on network traffic, etc.):
.PP
.nf
.br
    requestStarted( 1 )
.br
    requestFinished( 1, FALSE )
.br
.br
    requestStarted( 2 )
.br
    stateChanged( Connecting )
.br
    stateChanged( Sending )
.br
    dataSendProgress( 77, 77 )
.br
    stateChanged( Reading )
.br
    responseHeaderReceived( responseheader )
.br
    dataReadProgress( 5388, 0 )
.br
    readyRead( responseheader )
.br
    dataReadProgress( 18300, 0 )
.br
    readyRead( responseheader )
.br
    stateChanged( Connected )
.br
    requestFinished( 2, FALSE )
.br
.br
    done( FALSE )
.br
.br
    stateChanged( Closing )
.br
    stateChanged( Unconnected )
.br
.fi
.PP
The dataSendProgress() and dataReadProgress() signals in the above example are useful if you want to show a progressbar to inform the user about the progress of the download. The second argument is the total size of data. In certain cases it is not possible to know the total amount in advance, in which case the second argument is 0. (If you connect to a QProgressBar a total of 0 results in a busy indicator.)
.PP
When the response header is read, it is reported with the responseHeaderReceived() signal.
.PP
The readyRead() signal tells you that there is data ready to be read. The amount of data can then be queried with the bytesAvailable() function and it can be read with the readBlock() or readAll() functions.
.PP
If an error occurs during the execution of one of the commands in a sequence of commands, all the pending commands (i.e. scheduled, but not yet executed commands) are cleared and no signals are emitted for them.
.PP
For example, if you have the following sequence of reqeusts
.PP
.nf
.br
    http->setHost( "www.foo.bar" );       // id == 1
.br
    http->get( "/index.html" );           // id == 2
.br
    http->post( "register.html", data );  // id == 3
.br
.fi
.PP
and the get() request fails because the host lookup fails, then the post() request is never executed and the signals would look like this:
.PP
.nf
.br
    requestStarted( 1 )
.br
    requestFinished( 1, FALSE )
.br
.br
    requestStarted( 2 )
.br
    stateChanged( HostLookup )
.br
    requestFinished( 2, TRUE )
.br
.br
    done( TRUE )
.br
.br
    stateChanged( Unconnected )
.br
.fi
.PP
You can then get details about the error with the error() and errorString() functions. Note that only unexpected behaviour, like network failure is considered as an error. If the server response contains an error status, like a 404 response, this is reported as a normal response case. So you should always check the status code of the response header.
.PP
The functions currentId() and currentRequest() provide more information about the currently executing request.
.PP
The functions hasPendingRequests() and clearPendingRequests() allow you to query and clear the list of pending requests.
.PP
See also Qt Network Documentation, QNetworkProtocol, QUrlOperator, QFtp, and Input/Output and Networking.
.SS "Member Type Documentation"
.SH "QHttp::Error"
This enum identifies the error that occurred.
.TP
\fCQHttp::NoError\fR - No error occurred.
.TP
\fCQHttp::HostNotFound\fR - The host name lookup failed.
.TP
\fCQHttp::ConnectionRefused\fR - The server refused the connection.
.TP
\fCQHttp::UnexpectedClose\fR - The server closed the connection unexpectedly.
.TP
\fCQHttp::InvalidResponseHeader\fR - The server sent an invalid response header.
.TP
\fCQHttp::WrongContentLength\fR - The client could not read the content correctly because an error with respect to the content length occurred.
.TP
\fCQHttp::Aborted\fR - The request was aborted with abort().
.TP
\fCQHttp::UnknownError\fR - An error other than those specified above occurred.
.PP
See also error().
.SH "QHttp::State"
This enum is used to specify the state the client is in:
.TP
\fCQHttp::Unconnected\fR - There is no connection to the host.
.TP
\fCQHttp::HostLookup\fR - A host name lookup is in progress.
.TP
\fCQHttp::Connecting\fR - An attempt to connect to the host is in progress.
.TP
\fCQHttp::Sending\fR - The client is sending its request to the server.
.TP
\fCQHttp::Reading\fR - The client's request has been sent and the client is reading the server's response.
.TP
\fCQHttp::Connected\fR - The connection to the host is open, but the client is neither sending a request, nor waiting for a response.
.TP
\fCQHttp::Closing\fR - The connection is closing down, but is not yet closed. (The state will be Unconnected when the connection is closed.)
.PP
See also stateChanged() and state().
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QHttp::QHttp ()"
Constructs a QHttp object.
.SH "QHttp::QHttp ( QObject * parent, const char * name = 0 )"
Constructs a QHttp object. The parameters \fIparent\fR and \fIname\fR are passed on to the QObject constructor.
.SH "QHttp::QHttp ( const QString & hostname, Q_UINT16 port = 80, QObject * parent = 0, const char * name = 0 )"
Constructs a QHttp object. Subsequent requests are done by connecting to the server \fIhostname\fR on port \fIport\fR. The parameters \fIparent\fR and \fIname\fR are passed on to the QObject constructor.
.PP
See also setHost().
.SH "QHttp::~QHttp ()\fC [virtual]\fR"
Destroys the QHttp object. If there is an open connection, it is closed.
.SH "void QHttp::abort ()\fC [slot]\fR"
Aborts the current request and deletes all scheduled requests.
.PP
For the current request, the requestFinished() signal with the \fCerror\fR argument \fCTRUE\fR is emitted. For all other requests that are affected by the abort(), no signals are emitted.
.PP
Since this slot also deletes the scheduled requests, there are no requests left and the done() signal is emitted (with the \fCerror\fR argument \fCTRUE\fR).
.PP
See also clearPendingRequests().
.SH "Q_ULONG QHttp::bytesAvailable () const"
Returns the number of bytes that can be read from the response content at the moment.
.PP
See also get(), post(), request(), readyRead(), readBlock(), and readAll().
.SH "void QHttp::clearPendingRequests ()"
Deletes all pending requests from the list of scheduled requests. This does not affect the request that is being executed. If you want to stop this this as well, use abort().
.PP
See also hasPendingRequests() and abort().
.SH "int QHttp::closeConnection ()"
Closes the connection; this is useful if you have a keep-alive connection and want to close it.
.PP
For the requests issued with get(), post() and head(), QHttp sets the connection to be keep-alive. You can also do this using the header you pass to the request() function. QHttp only closes the connection to the HTTP server if the response header retquires it to do so.
.PP
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
.PP
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
.PP
If you want to close the connection immediately, you have to use abort() instead.
.PP
See also stateChanged(), abort(), requestStarted(), requestFinished(), and done().
.SH "QIODevice * QHttp::currentDestinationDevice () const"
Returns the QIODevice pointer that is used as to store the data of the HTTP request being executed. If there is no current request or if the request does not store the data to an IO device, this function returns 0.
.PP
This function can be used to delete the QIODevice in the slot connected to the requestFinished() signal.
.PP
See also get(), post(), and request().
.SH "int QHttp::currentId () const"
Returns the identifier of the HTTP request being executed or 0 if there is no request being executed (i.e. they've all finished).
.PP
See also currentRequest().
.SH "QHttpRequestHeader QHttp::currentRequest () const"
Returns the request header of the HTTP request being executed. If the request is one issued by setHost() or closeConnection(), it returns an invalid request header, i.e. QHttpRequestHeader::isValid() returns FALSE.
.PP
See also currentId().
.SH "QIODevice * QHttp::currentSourceDevice () const"
Returns the QIODevice pointer that is used as the data source of the HTTP request being executed. If there is no current request or if the request does not use an IO device as the data source, this function returns 0.
.PP
This function can be used to delete the QIODevice in the slot connected to the requestFinished() signal.
.PP
See also currentDestinationDevice(), post(), and request().
.SH "void QHttp::dataReadProgress ( int done, int total )\fC [signal]\fR"
This signal is emitted when this object reads data from a HTTP server to indicate the current progress of the download.
.PP
\fIdone\fR is the amount of data that has already arrived and \fItotal\fR is the total amount of data. It is possible that the total amount of data that should be transferred cannot be determined, in which case \fItotal\fR is 0.(If you connect to a QProgressBar, the progress bar shows a busy indicator if the total is 0).
.PP
\fBWarning:\fR \fIdone\fR and \fItotal\fR are not necessarily the size in bytes, since for large files these values might need to be" scaled" to avoid overflow.
.PP
See also dataSendProgress(), get(), post(), request(), and QProgressBar::progress.
.SH "void QHttp::dataSendProgress ( int done, int total )\fC [signal]\fR"
This signal is emitted when this object sends data to a HTTP server to inform it about the progress of the upload.
.PP
\fIdone\fR is the amount of data that has already arrived and \fItotal\fR is the total amount of data. It is possible that the total amount of data that should be transferred cannot be determined, in which case \fItotal\fR is 0.(If you connect to a QProgressBar, the progress bar shows a busy indicator if the total is 0).
.PP
\fBWarning:\fR \fIdone\fR and \fItotal\fR are not necessarily the size in bytes, since for large files these values might need to be" scaled" to avoid overflow.
.PP
See also dataReadProgress(), post(), request(), and QProgressBar::progress.
.SH "void QHttp::done ( bool error )\fC [signal]\fR"
This signal is emitted when the last pending request has finished; (it is emitted after the last request's requestFinished() signal). \fIerror\fR is TRUE if an error occurred during the processing; otherwise \fIerror\fR is FALSE.
.PP
See also requestFinished(), error(), and errorString().
.SH "Error QHttp::error () const"
Returns the last error that occurred. This is useful to find out what happened when receiving a requestFinished() or a done() signal with the \fCerror\fR argument \fCTRUE\fR.
.PP
If you start a new request, the error status is reset to NoError.
.SH "QString QHttp::errorString () const"
Returns a human-readable description of the last error that occurred. This is useful to present a error message to the user when receiving a requestFinished() or a done() signal with the \fCerror\fR argument \fCTRUE\fR.
.SH "int QHttp::get ( const QString & path, QIODevice * to = 0 )"
Sends a get request for \fIpath\fR to the server set by setHost() or as specified in the constructor.
.PP
\fIpath\fR must be an absolute path like \fC/index.html\fR or an absolute URI like http://www.trolltech.com/index.html.
.PP
If the IO device \fIto\fR is 0 the readyRead() signal is emitted every time new content data is available to read.
.PP
If the IO device \fIto\fR is not 0, the content data of the response is written directly to the device. Make sure that the \fIto\fR pointer is valid for the duration of the operation (it is safe to delete it when the requestFinished() signal is emitted).
.PP
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
.PP
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
.PP
See also setHost(), post(), head(), request(), requestStarted(), requestFinished(), and done().
.SH "bool QHttp::hasPendingRequests () const"
Returns TRUE if there are any requests scheduled that have not yet been executed; otherwise returns FALSE.
.PP
The request that is being executed is \fInot\fR considered as a scheduled request.
.PP
See also clearPendingRequests(), currentId(), and currentRequest().
.SH "int QHttp::head ( const QString & path )"
Sends a header request for \fIpath\fR to the server set by setHost() or as specified in the constructor.
.PP
\fIpath\fR must be an absolute path like \fC/index.html\fR or an absolute URI like http://www.trolltech.com/index.html.
.PP
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
.PP
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
.PP
See also setHost(), get(), post(), request(), requestStarted(), requestFinished(), and done().
.SH "int QHttp::post ( const QString & path, QIODevice * data, QIODevice * to = 0 )"
Sends a post request for \fIpath\fR to the server set by setHost() or as specified in the constructor.
.PP
\fIpath\fR must be an absolute path like \fC/index.html\fR or an absolute URI like http://www.trolltech.com/index.html.
.PP
The incoming data comes via the \fIdata\fR IO device.
.PP
If the IO device \fIto\fR is 0 the readyRead() signal is emitted every time new content data is available to read.
.PP
If the IO device \fIto\fR is not 0, the content data of the response is written directly to the device. Make sure that the \fIto\fR pointer is valid for the duration of the operation (it is safe to delete it when the requestFinished() signal is emitted).
.PP
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
.PP
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
.PP
See also setHost(), get(), head(), request(), requestStarted(), requestFinished(), and done().
.SH "int QHttp::post ( const QString & path, const QByteArray & data, QIODevice * to = 0 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
\fIdata\fR is used as the content data of the HTTP request.
.SH "QByteArray QHttp::readAll ()"
Reads all the bytes from the response content and returns them.
.PP
See also get(), post(), request(), readyRead(), bytesAvailable(), and readBlock().
.SH "Q_LONG QHttp::readBlock ( char * data, Q_ULONG maxlen )"
Reads \fImaxlen\fR bytes from the response content into \fIdata\fR and returns the number of bytes read. Returns -1 if an error occurred.
.PP
See also get(), post(), request(), readyRead(), bytesAvailable(), and readAll().
.SH "void QHttp::readyRead ( const QHttpResponseHeader & resp )\fC [signal]\fR"
This signal is emitted when there is new response data to read.
.PP
If you specified a device in the request where the data should be written to, then this signal is \fInot\fR emitted; instead the data is written directly to the device.
.PP
The response header is passed in \fIresp\fR.
.PP
You can read the data with the readAll() or readBlock() functions
.PP
This signal is useful if you want to process the data in chunks as soon as it becomes available. If you are only interested in the complete data, just connect to the requestFinished() signal and read the data then instead.
.PP
See also get(), post(), request(), readAll(), readBlock(), and bytesAvailable().
.SH "int QHttp::request ( const QHttpRequestHeader & header, QIODevice * data = 0, QIODevice * to = 0 )"
Sends a request to the server set by setHost() or as specified in the constructor. Uses the \fIheader\fR as the HTTP request header. You are responsible for setting up a header that is appropriate for your request.
.PP
The incoming data comes via the \fIdata\fR IO device.
.PP
If the IO device \fIto\fR is 0 the readyRead() signal is emitted every time new content data is available to read.
.PP
If the IO device \fIto\fR is not 0, the content data of the response is written directly to the device. Make sure that the \fIto\fR pointer is valid for the duration of the operation (it is safe to delete it when the requestFinished() signal is emitted).
.PP
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
.PP
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
.PP
See also setHost(), get(), post(), head(), requestStarted(), requestFinished(), and done().
.SH "int QHttp::request ( const QHttpRequestHeader & header, const QByteArray & data, QIODevice * to = 0 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
\fIdata\fR is used as the content data of the HTTP request.
.SH "void QHttp::requestFinished ( int id, bool error )\fC [signal]\fR"
This signal is emitted when processing the request identified by \fIid\fR has finished. \fIerror\fR is TRUE if an error occurred during the processing; otherwise \fIerror\fR is FALSE.
.PP
See also requestStarted(), done(), error(), and errorString().
.SH "void QHttp::requestStarted ( int id )\fC [signal]\fR"
This signal is emitted when processing the request identified by \fIid\fR starts.
.PP
See also requestFinished() and done().
.SH "void QHttp::responseHeaderReceived ( const QHttpResponseHeader & resp )\fC [signal]\fR"
This signal is emitted when the HTTP header of a server response is available. The header is passed in \fIresp\fR.
.PP
See also get(), post(), head(), request(), and readyRead().
.SH "int QHttp::setHost ( const QString & hostname, Q_UINT16 port = 80 )"
Sets the HTTP server that is used for requests to \fIhostname\fR on port \fIport\fR.
.PP
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
.PP
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
.PP
See also get(), post(), head(), request(), requestStarted(), requestFinished(), and done().
.SH "State QHttp::state () const"
Returns the current state of the object. When the state changes, the stateChanged() signal is emitted.
.PP
See also State and stateChanged().
.SH "void QHttp::stateChanged ( int state )\fC [signal]\fR"
This signal is emitted when the state of the QHttp object changes. The argument \fIstate\fR is the new state of the connection; it is one of the State values.
.PP
This usually happens when a request is started, but it can also happen when the server closes the connection or when a call to closeConnection() succeeded.
.PP
See also get(), post(), head(), request(), closeConnection(), state(), and State.

.SH "SEE ALSO"
.BR http://doc.trolltech.com/qhttp.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qhttp.3qt) and the Qt
version (3.3.8).