|
|
|
// This is the SIP interface definition for TQHttp, TQHttpHeader,
|
|
|
|
// TQHttpRequestHeader and TQHttpResponseHeader.
|
|
|
|
//
|
|
|
|
// Copyright (c) 2007
|
|
|
|
// Riverbank Computing Limited <info@riverbankcomputing.co.uk>
|
|
|
|
//
|
|
|
|
// This file is part of PyTQt.
|
|
|
|
//
|
|
|
|
// This copy of PyTQt is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU General Public License as published by the Free
|
|
|
|
// Software Foundation; either version 2, or (at your option) any later
|
|
|
|
// version.
|
|
|
|
//
|
|
|
|
// PyTQt is supplied in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
// details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along with
|
|
|
|
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
|
|
|
|
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
|
|
|
|
%ExportedDoc
|
|
|
|
<Sect2><Title>TQHttp (TQt v3+)</Title>
|
|
|
|
<FuncSynopsis>
|
|
|
|
<FuncDef>Q_LONG <Function>readBlock</Function></FuncDef>
|
|
|
|
<ParamDef>char *<Parameter>data</Parameter></ParamDef>
|
|
|
|
<ParamDef>Q_ULONG <Parameter>maxlen</Parameter></ParamDef>
|
|
|
|
</FuncSynopsis>
|
|
|
|
<Para>
|
|
|
|
This takes a single <Literal>maxlen</Literal> parameter. The
|
|
|
|
<Literal>data</Literal> is returned if there was no error, otherwise
|
|
|
|
<Literal>None</Literal> is returned.
|
|
|
|
</Para>
|
|
|
|
</Sect2>
|
|
|
|
|
|
|
|
<Sect2><Title>TQHttpHeader (TQt v3.1+)</Title>
|
|
|
|
<Para>
|
|
|
|
<Literal>TQHttpHeader</Literal> is fully implemented.
|
|
|
|
</Para>
|
|
|
|
</Sect2>
|
|
|
|
|
|
|
|
<Sect2><Title>TQHttpRequestHeader (TQt v3.1+)</Title>
|
|
|
|
<Para>
|
|
|
|
<Literal>TQHttpRequestHeader</Literal> is fully implemented.
|
|
|
|
</Para>
|
|
|
|
</Sect2>
|
|
|
|
|
|
|
|
<Sect2><Title>TQHttpResponseHeader (TQt v3.1+)</Title>
|
|
|
|
<Para>
|
|
|
|
<Literal>TQHttpResponseHeader</Literal> is fully implemented.
|
|
|
|
</Para>
|
|
|
|
</Sect2>
|
|
|
|
%End
|
|
|
|
|
|
|
|
|
|
|
|
%If (TQt_NETWORKPROTOCOL_HTTP)
|
|
|
|
%If (TQt_3_1_0 -)
|
|
|
|
|
|
|
|
class TQHttpHeader
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <tqhttp.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
TQHttpHeader();
|
|
|
|
TQHttpHeader(const TQHttpHeader &);
|
|
|
|
TQHttpHeader(const TQString &);
|
|
|
|
virtual ~TQHttpHeader();
|
|
|
|
|
|
|
|
TQString value(const TQString &) const;
|
|
|
|
void setValue(const TQString &,const TQString &);
|
|
|
|
void removeValue(const TQString &);
|
|
|
|
|
|
|
|
TQStringList keys() const;
|
|
|
|
bool hasKey(const TQString &) const;
|
|
|
|
|
|
|
|
bool hasContentLength() const;
|
|
|
|
uint contentLength() const;
|
|
|
|
void setContentLength(int);
|
|
|
|
|
|
|
|
bool hasContentType() const;
|
|
|
|
TQString contentType() const;
|
|
|
|
void setContentType(const TQString &);
|
|
|
|
|
|
|
|
virtual TQString toString() const;
|
|
|
|
bool isValid() const;
|
|
|
|
|
|
|
|
virtual int majorVersion() const = 0;
|
|
|
|
virtual int minorVersion() const = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool parseLine(const TQString &,int);
|
|
|
|
bool parse(const TQString &);
|
|
|
|
void setValid(bool);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TQHttpResponseHeader : TQHttpHeader
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <tqhttp.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
TQHttpResponseHeader();
|
|
|
|
TQHttpResponseHeader(const TQHttpResponseHeader &);
|
|
|
|
|
|
|
|
int statusCode() const;
|
|
|
|
TQString reasonPhrase() const;
|
|
|
|
|
|
|
|
int majorVersion() const;
|
|
|
|
int minorVersion() const;
|
|
|
|
|
|
|
|
TQString toString() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool parseLine(const TQString &,int);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TQHttpRequestHeader : TQHttpHeader
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <tqhttp.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
TQHttpRequestHeader();
|
|
|
|
TQHttpRequestHeader(const TQString &,const TQString &,int = 1,int = 1);
|
|
|
|
TQHttpRequestHeader(const TQHttpRequestHeader &);
|
|
|
|
TQHttpRequestHeader(const TQString &);
|
|
|
|
|
|
|
|
void setRequest(const TQString &,const TQString &,int = 1,int = 1);
|
|
|
|
|
|
|
|
TQString method() const;
|
|
|
|
TQString path() const;
|
|
|
|
|
|
|
|
int majorVersion() const;
|
|
|
|
int minorVersion() const;
|
|
|
|
|
|
|
|
TQString toString() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool parseLine(const TQString &,int);
|
|
|
|
};
|
|
|
|
|
|
|
|
%End
|
|
|
|
|
|
|
|
|
|
|
|
%If (TQt_3_0_0 -)
|
|
|
|
|
|
|
|
class TQHttp : TQNetworkProtocol
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <tqhttp.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
TQHttp();
|
|
|
|
%If (TQt_3_1_0 -)
|
|
|
|
TQHttp(TQObject * /TransferThis/,const char * = 0);
|
|
|
|
TQHttp(const TQString &,Q_UINT16 = 80,TQObject * /TransferThis/ = 0,
|
|
|
|
const char * = 0);
|
|
|
|
virtual ~TQHttp();
|
|
|
|
%End
|
|
|
|
|
|
|
|
int supportedOperations() const;
|
|
|
|
|
|
|
|
%If (TQt_3_1_0 -)
|
|
|
|
enum State {
|
|
|
|
Unconnected,
|
|
|
|
HostLookup,
|
|
|
|
Connecting,
|
|
|
|
Sending,
|
|
|
|
Reading,
|
|
|
|
Connected,
|
|
|
|
Closing
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Error {
|
|
|
|
NoError,
|
|
|
|
UnknownError,
|
|
|
|
HostNotFound,
|
|
|
|
ConnectionRefused,
|
|
|
|
UnexpectedClose,
|
|
|
|
InvalidResponseHeader,
|
|
|
|
WrongContentLength,
|
|
|
|
Aborted
|
|
|
|
};
|
|
|
|
|
|
|
|
int setHost(const TQString &,Q_UINT16 = 80);
|
|
|
|
|
|
|
|
int get(const TQString &,TQIODevice * = 0) /ReleaseGIL/;
|
|
|
|
int post(const TQString &,TQIODevice *,TQIODevice * = 0) /ReleaseGIL/;
|
|
|
|
int post(const TQString &,const TQByteArray &,
|
|
|
|
TQIODevice * = 0) /ReleaseGIL/;
|
|
|
|
int head(const TQString &) /ReleaseGIL/;
|
|
|
|
int request(const TQHttpRequestHeader &,TQIODevice * = 0,
|
|
|
|
TQIODevice * = 0) /ReleaseGIL/;
|
|
|
|
int request(const TQHttpRequestHeader &,const TQByteArray &,
|
|
|
|
TQIODevice * = 0) /ReleaseGIL/;
|
|
|
|
|
|
|
|
int closeConnection();
|
|
|
|
|
|
|
|
unsigned long bytesAvailable() const;
|
|
|
|
|
|
|
|
SIP_PYOBJECT readBlock(Q_ULONG) /ReleaseGIL/ [Q_LONG (char *,Q_ULONG)];
|
|
|
|
%MethodCode
|
|
|
|
char *buf;
|
|
|
|
|
|
|
|
if ((buf = (char *)sipMalloc(a0)) == NULL)
|
|
|
|
sipIsErr = 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Q_LONG actlen;
|
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
actlen = sipCpp -> TQHttp::readBlock(buf,a0);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (actlen < 0)
|
|
|
|
{
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
sipRes = Py_None;
|
|
|
|
}
|
|
|
|
else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL)
|
|
|
|
sipIsErr = 1;
|
|
|
|
|
|
|
|
sipFree((ANY *)buf);
|
|
|
|
}
|
|
|
|
%End
|
|
|
|
|
|
|
|
TQByteArray readAll() /ReleaseGIL/;
|
|
|
|
|
|
|
|
int currentId() const;
|
|
|
|
TQIODevice *currentSourceDevice() const;
|
|
|
|
TQIODevice *currentDestinationDevice() const;
|
|
|
|
TQHttpRequestHeader currentRequest() const;
|
|
|
|
bool hasPendingRequests() const;
|
|
|
|
void clearPendingRequests();
|
|
|
|
|
|
|
|
State state() const;
|
|
|
|
|
|
|
|
Error error() const;
|
|
|
|
TQString errorString() const;
|
|
|
|
%End
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
%If (TQt_3_1_0 -)
|
|
|
|
void abort();
|
|
|
|
%End
|
|
|
|
|
|
|
|
signals:
|
|
|
|
%If (TQt_3_1_0 -)
|
|
|
|
void stateChanged(int);
|
|
|
|
void responseHeaderReceived(const TQHttpResponseHeader &);
|
|
|
|
void readyRead(const TQHttpResponseHeader &);
|
|
|
|
void dataSendProgress(int,int);
|
|
|
|
void dataReadProgress(int,int);
|
|
|
|
|
|
|
|
void requestStarted(int);
|
|
|
|
void requestFinished(int,bool);
|
|
|
|
void done(bool);
|
|
|
|
%End
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void operationGet(TQNetworkOperation *);
|
|
|
|
void operationPut(TQNetworkOperation *);
|
|
|
|
|
|
|
|
%If (TQt_3_1_0 -)
|
|
|
|
void timerEvent(TQTimerEvent *);
|
|
|
|
%End
|
|
|
|
};
|
|
|
|
|
|
|
|
%End
|
|
|
|
%End
|